Class: FFI::Libfuse::JobPool
- Inherits:
-
Object
- Object
- FFI::Libfuse::JobPool
- Defined in:
- lib/ffi/libfuse/job_pool.rb
Overview
A JobPool is a ThreadPool whose worker threads are consuming from a Queue
Instance Method Summary collapse
-
#close ⇒ self
Close the JobPool.
- #group ⇒ Object
-
#initialize(**options, &worker) ⇒ JobPool
constructor
Create a Job Pool.
-
#join(&block) ⇒ self
Join the JobPool.
- #list ⇒ Object
-
#schedule(*args) ⇒ self
(also: #<<, #push)
Schedule a job.
Constructor Details
#initialize(**options, &worker) ⇒ JobPool
Create a Job Pool
13 14 15 16 |
# File 'lib/ffi/libfuse/job_pool.rb', line 13 def initialize(**, &worker) @jq = Queue.new @tp = ThreadPool.new(**) { (args = @jq.pop) && worker.call(*args) } end |
Instance Method Details
#close ⇒ self
Close the JobPool
30 31 32 33 |
# File 'lib/ffi/libfuse/job_pool.rb', line 30 def close @jq.close self end |
#group ⇒ Object
48 49 50 |
# File 'lib/ffi/libfuse/job_pool.rb', line 48 def group @tp.group end |
#join(&block) ⇒ self
Join the JobPool
37 38 39 40 |
# File 'lib/ffi/libfuse/job_pool.rb', line 37 def join(&block) @tp.join(&block) self end |
#list ⇒ Object
43 44 45 |
# File 'lib/ffi/libfuse/job_pool.rb', line 43 def list @tp.list end |
#schedule(*args) ⇒ self Also known as: <<, push
Schedule a job
21 22 23 24 |
# File 'lib/ffi/libfuse/job_pool.rb', line 21 def schedule(*args) @jq.push(args) self end |