Module: MutexCode
- Included in:
- ContextR::ClassMethods
- Defined in:
- lib/contextr/modules/mutex_code.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#is_blocked? ⇒ Boolean
13 14 15 |
# File 'lib/contextr/modules/mutex_code.rb', line 13 def is_blocked? semaphore.locked? end |
#only_once ⇒ Object
17 18 19 20 21 |
# File 'lib/contextr/modules/mutex_code.rb', line 17 def only_once synchronized do yield end unless is_blocked? end |
#semaphore ⇒ Object
3 4 5 |
# File 'lib/contextr/modules/mutex_code.rb', line 3 def semaphore @semaphore ||= Mutex.new end |
#synchronized ⇒ Object
7 8 9 10 11 |
# File 'lib/contextr/modules/mutex_code.rb', line 7 def synchronized semaphore.synchronize do yield end end |