Module: Dalli::Threadsafe
- Defined in:
- lib/dalli/options.rb
Overview
Make Dalli threadsafe by using a lock around all public server methods.
Dalli::Server.extend(Dalli::Threadsafe)
Class Method Summary collapse
Instance Method Summary collapse
- #alive? ⇒ Boolean
- #close ⇒ Object
- #init_threadsafe ⇒ Object
- #lock! ⇒ Object
- #request(op, *args) ⇒ Object
- #unlock! ⇒ Object
Class Method Details
.extended(obj) ⇒ Object
12 13 14 |
# File 'lib/dalli/options.rb', line 12 def self.extended(obj) obj.init_threadsafe end |
Instance Method Details
#alive? ⇒ Boolean
22 23 24 25 26 |
# File 'lib/dalli/options.rb', line 22 def alive? @lock.synchronize do super end end |
#close ⇒ Object
28 29 30 31 32 |
# File 'lib/dalli/options.rb', line 28 def close @lock.synchronize do super end end |
#init_threadsafe ⇒ Object
42 43 44 |
# File 'lib/dalli/options.rb', line 42 def init_threadsafe @lock = Monitor.new end |
#lock! ⇒ Object
34 35 36 |
# File 'lib/dalli/options.rb', line 34 def lock! @lock.mon_enter end |
#request(op, *args) ⇒ Object
16 17 18 19 20 |
# File 'lib/dalli/options.rb', line 16 def request(op, *args) @lock.synchronize do super end end |
#unlock! ⇒ Object
38 39 40 |
# File 'lib/dalli/options.rb', line 38 def unlock! @lock.mon_exit end |