Class: Green::Pool
Instance Attribute Summary collapse
-
#semaphore ⇒ Object
readonly
Returns the value of attribute semaphore.
Attributes inherited from Group
Instance Method Summary collapse
-
#initialize(*args) ⇒ Pool
constructor
A new instance of Pool.
- #join ⇒ Object
- #spawn(*args, &blk) ⇒ Object
Methods inherited from Group
#add, #apply, #discard, #enumerator, #kill, #size
Constructor Details
Instance Attribute Details
#semaphore ⇒ Object (readonly)
Returns the value of attribute semaphore.
70 71 72 |
# File 'lib/green/group.rb', line 70 def semaphore @semaphore end |
Instance Method Details
#join ⇒ Object
88 89 90 |
# File 'lib/green/group.rb', line 88 def join semaphore.wait end |
#spawn(*args, &blk) ⇒ Object
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/green/group.rb', line 77 def spawn(*args, &blk) semaphore.acquire super() do begin blk.call(*args) ensure semaphore.release end end end |