class Aerospike::Task
Public Class Methods
new(cluster, done)
click to toggle source
# File lib/aerospike/task/task.rb, line 27 def initialize(cluster, done) @cluster = cluster @done = Atomic.new(done) @done_thread = Atomic.new(nil) self end
Public Instance Methods
completed?()
click to toggle source
# File lib/aerospike/task/task.rb, line 62 def completed? @done.value ||= all_nodes_done? end
wait_till_completed(poll_interval = 0.1, allowed_failures = 3)
click to toggle source
# File lib/aerospike/task/task.rb, line 35 def wait_till_completed(poll_interval = 0.1, allowed_failures = 3) return true if @done.value # make sure there will be only ONE thread polling for completetion status @done_thread.update do |dt| dt ? dt : Thread.new do Thread.current.abort_on_exception = true failures = 0 while true begin sleep(poll_interval.to_f) break if completed? rescue => e Aerospike.logger.error(e) break if failures > allowed_failures failures += 1 end end end end # wait for the poll thread to finish @done_thread.value.join # in case of errors and exceptions, the @done value might be false @done.value end