Class: VSphereCloud::LeaseUpdater
- Inherits:
-
Object
- Object
- VSphereCloud::LeaseUpdater
- Defined in:
- lib/cloud/vsphere/lease_updater.rb
Instance Attribute Summary collapse
-
#progress ⇒ Object
Returns the value of attribute progress.
Instance Method Summary collapse
- #abort ⇒ Object
- #finish ⇒ Object
-
#initialize(client, lease) ⇒ LeaseUpdater
constructor
A new instance of LeaseUpdater.
- #run ⇒ Object
Constructor Details
#initialize(client, lease) ⇒ LeaseUpdater
Returns a new instance of LeaseUpdater.
5 6 7 8 9 10 11 12 |
# File 'lib/cloud/vsphere/lease_updater.rb', line 5 def initialize(client, lease) @progress = 0 @client = client @lease = lease @state = :running @lock = Mutex.new @thread = Thread.new { run } end |
Instance Attribute Details
#progress ⇒ Object
Returns the value of attribute progress.
3 4 5 |
# File 'lib/cloud/vsphere/lease_updater.rb', line 3 def progress @progress end |
Instance Method Details
#abort ⇒ Object
24 25 26 27 28 29 |
# File 'lib/cloud/vsphere/lease_updater.rb', line 24 def abort @lock.synchronize do @state = :abort @lease.abort end end |
#finish ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/cloud/vsphere/lease_updater.rb', line 31 def finish @lock.synchronize do @state = :finish @lease.progress(100) @lease.complete end end |
#run ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/cloud/vsphere/lease_updater.rb', line 14 def run loop do @lock.synchronize do break if @state != :running @lease.progress(@progress) end sleep(1) end end |