Class: Aerospike::Task
- Inherits:
-
Object
show all
- Defined in:
- lib/aerospike/task/task.rb
Instance Method Summary
collapse
Constructor Details
#initialize(cluster, done) ⇒ Task
Returns a new instance of Task.
27
28
29
30
31
32
33
|
# 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
|
Instance Method Details
#completed? ⇒ Boolean
62
63
64
|
# 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) ⇒ Object
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
60
|
# File 'lib/aerospike/task/task.rb', line 35
def wait_till_completed(poll_interval = 0.1, allowed_failures = 3)
return true if @done.value
@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
@done_thread.value.join
@done.value
end
|