Module: ZeevexConcurrency::ThreadPool::Stubs
- Included in:
- EventLoopAdapter, FixedPool, InlineThreadPool, ThreadPerJobPool
- Defined in:
- lib/zeevex_concurrency/thread_pool.rb
Instance Method Summary collapse
-
#backlog ⇒ Object
how many tasks are waiting.
- #busy? ⇒ Boolean
- #busy_count ⇒ Object
-
#flush ⇒ Object
flush any queued but un-executed tasks.
- #free_count ⇒ Object
-
#join ⇒ Object
Returns after all currently enqueued tasks complete - does not guarantee that tasks are not enqueued while waiting.
- #worker_count ⇒ Object
Instance Method Details
#backlog ⇒ Object
how many tasks are waiting
48 49 50 |
# File 'lib/zeevex_concurrency/thread_pool.rb', line 48 def backlog 0 end |
#busy? ⇒ Boolean
9 10 11 |
# File 'lib/zeevex_concurrency/thread_pool.rb', line 9 def busy? free_count == 0 end |
#busy_count ⇒ Object
17 18 19 |
# File 'lib/zeevex_concurrency/thread_pool.rb', line 17 def busy_count -1 end |
#flush ⇒ Object
flush any queued but un-executed tasks
28 29 30 |
# File 'lib/zeevex_concurrency/thread_pool.rb', line 28 def flush true end |
#free_count ⇒ Object
21 22 23 |
# File 'lib/zeevex_concurrency/thread_pool.rb', line 21 def free_count (worker_count - busy_count) end |
#join ⇒ Object
Returns after all currently enqueued tasks complete - does not guarantee that tasks are not enqueued while waiting
36 37 38 39 40 41 42 43 |
# File 'lib/zeevex_concurrency/thread_pool.rb', line 36 def join latch = CountDownLatch.new(1) enqueue do latch.countdown! end latch.wait true end |
#worker_count ⇒ Object
13 14 15 |
# File 'lib/zeevex_concurrency/thread_pool.rb', line 13 def worker_count -1 end |