Class: Lifeguard::InfiniteThreadpool
Constant Summary
Constants inherited
from Threadpool
Threadpool::DEFAULT_POOL_SIZE, Threadpool::DEFAULT_REAPING_INTERVAL
Instance Attribute Summary
Attributes inherited from Threadpool
#name, #options, #pool_size
Instance Method Summary
collapse
Methods inherited from Threadpool
#busy?, #busy_size, #timeout!, #timeout?
Constructor Details
Returns a new instance of InfiniteThreadpool.
7
8
9
10
11
|
# File 'lib/lifeguard/infinite_threadpool.rb', line 7
def initialize(opts = {})
super(opts)
@shutdown = false
@super_async_mutex = ::Mutex.new
end
|
Instance Method Details
#async(*args, &block) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/lifeguard/infinite_threadpool.rb', line 13
def async(*args, &block)
return false if @shutdown
if busy?
block.call(*args) rescue nil
else
super(*args, &block)
end
return true
end
|
#kill!(*args) ⇒ Object
25
26
27
28
|
# File 'lib/lifeguard/infinite_threadpool.rb', line 25
def kill!(*args)
super
@shutdown = true
end
|
#on_thread_exit(thread) ⇒ Object
30
31
32
33
34
|
# File 'lib/lifeguard/infinite_threadpool.rb', line 30
def on_thread_exit(thread)
return_value = super
check_queued_jobs
return_value
end
|
#prune_busy_threads ⇒ Object
36
37
38
39
40
|
# File 'lib/lifeguard/infinite_threadpool.rb', line 36
def prune_busy_threads
response = super
check_queued_jobs
response
end
|
#shutdown(*args) ⇒ Object
42
43
44
45
|
# File 'lib/lifeguard/infinite_threadpool.rb', line 42
def shutdown(*args)
@shutdown = true
super
end
|