Class: Dynflow::Semaphores::Abstract
- Inherits:
-
Object
- Object
- Dynflow::Semaphores::Abstract
- Defined in:
- lib/dynflow/semaphores/abstract.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#drain ⇒ Object
Requests all tickets Returns all free tickets from the semaphore.
-
#get(n = 1) ⇒ Object
Tries to get n tickets Returns n if the semaphore has free >= n Returns free if n > free.
-
#get_waiting ⇒ Object
Gets first object from the queue.
-
#has_waiting? ⇒ Boolean
Checks if there are objects in the queue.
-
#release(n = 1) ⇒ Object
Returns n tickets to the semaphore.
-
#save ⇒ Object
Saves the semaphore’s state to some persistent storage.
-
#wait(thing) ⇒ Object
Tries to get ticket from the semaphore Returns true if thing got a ticket Rturns false otherwise and puts the thing into the semaphore’s queue.
Instance Method Details
#drain ⇒ Object
Requests all tickets Returns all free tickets from the semaphore
42 43 44 |
# File 'lib/dynflow/semaphores/abstract.rb', line 42 def drain raise NotImplementedError end |
#get(n = 1) ⇒ Object
Tries to get n tickets Returns n if the semaphore has free >= n Returns free if n > free
36 37 38 |
# File 'lib/dynflow/semaphores/abstract.rb', line 36 def get(n = 1) raise NotImplementedErrorn end |
#get_waiting ⇒ Object
Gets first object from the queue
14 15 16 |
# File 'lib/dynflow/semaphores/abstract.rb', line 14 def get_waiting raise NotImplementedError end |
#has_waiting? ⇒ Boolean
Checks if there are objects in the queue
19 20 21 |
# File 'lib/dynflow/semaphores/abstract.rb', line 19 def has_waiting? raise NotImpelementedError end |
#release(n = 1) ⇒ Object
Returns n tickets to the semaphore
24 25 26 |
# File 'lib/dynflow/semaphores/abstract.rb', line 24 def release(n = 1) raise NotImplementedError end |
#save ⇒ Object
Saves the semaphore’s state to some persistent storage
29 30 31 |
# File 'lib/dynflow/semaphores/abstract.rb', line 29 def save raise NotImplementedError end |
#wait(thing) ⇒ Object
Tries to get ticket from the semaphore Returns true if thing got a ticket Rturns false otherwise and puts the thing into the semaphore’s queue
9 10 11 |
# File 'lib/dynflow/semaphores/abstract.rb', line 9 def wait(thing) raise NotImplementedError end |