Module: Camayoc::ThreadSafety
- Included in:
- Handlers::IO, Handlers::Memory, Handlers::Statsd
- Defined in:
- lib/camayoc/thread_safety.rb
Defined Under Namespace
Classes: PlaceboLock
Instance Method Summary collapse
- #synchronize ⇒ Object
-
#thread_safe=(value) ⇒ Object
Ideally this should be called from your constructor.
- #thread_safe? ⇒ Boolean
Instance Method Details
#synchronize ⇒ Object
19 20 21 |
# File 'lib/camayoc/thread_safety.rb', line 19 def synchronize lock.synchronize { yield } end |
#thread_safe=(value) ⇒ Object
Ideally this should be called from your constructor
11 12 13 |
# File 'lib/camayoc/thread_safety.rb', line 11 def thread_safe=(value) @lock = value ? Mutex.new : PlaceboLock.new end |
#thread_safe? ⇒ Boolean
15 16 17 |
# File 'lib/camayoc/thread_safety.rb', line 15 def thread_safe? lock.is_a?(Mutex) end |