Class: VirtualBox::COM::Interface::Version_4_0_X::Progress
- Inherits:
-
AbstractInterface
- Object
- AbstractInterface
- VirtualBox::COM::Interface::Version_4_0_X::Progress
- Defined in:
- lib/virtualbox/com/interface/4.0.x/progress.rb
Constant Summary collapse
- IID =
"856aa038-853f-42e2-acf7-6e7b02dbe294"
Instance Attribute Summary
Attributes inherited from AbstractInterface
Instance Method Summary collapse
-
#wait(interval_percent = 1) ⇒ Object
This method blocks the execution while the operations represented by this Progress object execute, but yields a block every ‘x` percent (interval given in parameters).
Methods inherited from AbstractInterface
#call_function, function, functions, #has_function?, #has_property?, #initialize, #inspect, #member, member, members, #members, properties, property, #read_property, #write_property
Constructor Details
This class inherits a constructor from VirtualBox::COM::AbstractInterface
Instance Method Details
#wait(interval_percent = 1) ⇒ Object
This method blocks the execution while the operations represented by this VirtualBox::COM::Interface::Version_4_0_X::Progress object execute, but yields a block every ‘x` percent (interval given in parameters).
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/virtualbox/com/interface/4.0.x/progress.rb', line 34 def wait(interval_percent=1) # If no block is given we just wait until completion, not worrying # about tracking percentages. if !block_given? wait_for_completion(-1) return end # Initial value forces the 0% yield last_reported = -100 while true delta = percent - last_reported last_reported += delta yield self if delta >= interval_percent # This either sleeps for half a second or returns on # completion wait_for_completion(500) break if completed || canceled # Pass off execution so other threads can run Thread.pass end end |