Class: Baykit::BayServer::Docker::SendFile::FileContent
- Inherits:
-
Object
- Object
- Baykit::BayServer::Docker::SendFile::FileContent
- Defined in:
- lib/baykit/bayserver/docker/send_file/file_content.rb
Instance Attribute Summary collapse
-
#bytes_loaded ⇒ Object
Returns the value of attribute bytes_loaded.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#content_length ⇒ Object
readonly
Returns the value of attribute content_length.
-
#loaded_time ⇒ Object
readonly
Returns the value of attribute loaded_time.
-
#lock ⇒ Object
readonly
Returns the value of attribute lock.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#waiters ⇒ Object
readonly
Returns the value of attribute waiters.
Instance Method Summary collapse
- #add_waiter(waiter) ⇒ Object
- #complete ⇒ Object
-
#initialize(path, length) ⇒ FileContent
constructor
A new instance of FileContent.
- #is_loaded ⇒ Object
- #wakeup_waiter(waiter) ⇒ Object
Constructor Details
#initialize(path, length) ⇒ FileContent
Returns a new instance of FileContent.
22 23 24 25 26 27 28 29 30 |
# File 'lib/baykit/bayserver/docker/send_file/file_content.rb', line 22 def initialize(path, length) @path = path @content = "" @content_length = length @bytes_loaded = 0 @loaded_time = Time.now.to_i @waiters = [] @lock = Mutex.new end |
Instance Attribute Details
#bytes_loaded ⇒ Object
Returns the value of attribute bytes_loaded.
13 14 15 |
# File 'lib/baykit/bayserver/docker/send_file/file_content.rb', line 13 def bytes_loaded @bytes_loaded end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
11 12 13 |
# File 'lib/baykit/bayserver/docker/send_file/file_content.rb', line 11 def content @content end |
#content_length ⇒ Object (readonly)
Returns the value of attribute content_length.
12 13 14 |
# File 'lib/baykit/bayserver/docker/send_file/file_content.rb', line 12 def content_length @content_length end |
#loaded_time ⇒ Object (readonly)
Returns the value of attribute loaded_time.
14 15 16 |
# File 'lib/baykit/bayserver/docker/send_file/file_content.rb', line 14 def loaded_time @loaded_time end |
#lock ⇒ Object (readonly)
Returns the value of attribute lock.
16 17 18 |
# File 'lib/baykit/bayserver/docker/send_file/file_content.rb', line 16 def lock @lock end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/baykit/bayserver/docker/send_file/file_content.rb', line 10 def path @path end |
#waiters ⇒ Object (readonly)
Returns the value of attribute waiters.
15 16 17 |
# File 'lib/baykit/bayserver/docker/send_file/file_content.rb', line 15 def waiters @waiters end |
Instance Method Details
#add_waiter(waiter) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/baykit/bayserver/docker/send_file/file_content.rb', line 36 def add_waiter(waiter) @lock.synchronize do if is_loaded wakeup_waiter(waiter) else waiters << waiter end end end |
#complete ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/baykit/bayserver/docker/send_file/file_content.rb', line 46 def complete() @lock.synchronize do @waiters.each do |waiter| wakeup_waiter(waiter) end waiters.clear end end |
#is_loaded ⇒ Object
32 33 34 |
# File 'lib/baykit/bayserver/docker/send_file/file_content.rb', line 32 def is_loaded() return @bytes_loaded == @content_length end |