Class: Bob::BackgroundEngines::Threaded
- Defined in:
- lib/bob/background_engines/threaded.rb
Defined Under Namespace
Classes: ThreadPool
Instance Method Summary collapse
- #call(job) ⇒ Object
-
#initialize(pool_size = 2) ⇒ Threaded
constructor
A new instance of Threaded.
- #njobs ⇒ Object
- #wait! ⇒ Object
Constructor Details
#initialize(pool_size = 2) ⇒ Threaded
Returns a new instance of Threaded.
7 8 9 |
# File 'lib/bob/background_engines/threaded.rb', line 7 def initialize(pool_size = 2) @pool = ThreadPool.new(pool_size) end |
Instance Method Details
#call(job) ⇒ Object
11 12 13 |
# File 'lib/bob/background_engines/threaded.rb', line 11 def call(job) @pool << job end |
#njobs ⇒ Object
15 16 17 |
# File 'lib/bob/background_engines/threaded.rb', line 15 def njobs @pool.njobs end |
#wait! ⇒ Object
19 20 21 |
# File 'lib/bob/background_engines/threaded.rb', line 19 def wait! Thread.pass until @pool.njobs == 0 end |