Class: ThreadPool
- Inherits:
-
Object
- Object
- ThreadPool
- Defined in:
- lib/thread_pool.rb
Instance Attribute Summary collapse
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(tasks, thread_limit, thread_object = Thread) ⇒ ThreadPool
constructor
A new instance of ThreadPool.
Constructor Details
#initialize(tasks, thread_limit, thread_object = Thread) ⇒ ThreadPool
Returns a new instance of ThreadPool.
4 5 6 7 8 |
# File 'lib/thread_pool.rb', line 4 def initialize(tasks, thread_limit, thread_object=Thread) @queue = populate_queue(tasks) @thread_limit = thread_limit @thread_object = thread_object end |
Instance Attribute Details
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
2 3 4 |
# File 'lib/thread_pool.rb', line 2 def queue @queue end |
Instance Method Details
#execute ⇒ Object
10 11 12 13 14 |
# File 'lib/thread_pool.rb', line 10 def execute (0...@thread_limit).map do create_worker end.each(&:join) end |