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
- #multi_response_abort ⇒ Object
- #multi_response_nonblock ⇒ Object
- #multi_response_start ⇒ 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
60 61 62 |
# File 'lib/dalli/options.rb', line 60 def init_threadsafe @lock = Monitor.new end |
#lock! ⇒ Object
52 53 54 |
# File 'lib/dalli/options.rb', line 52 def lock! @lock.mon_enter end |
#multi_response_abort ⇒ Object
46 47 48 49 50 |
# File 'lib/dalli/options.rb', line 46 def multi_response_abort @lock.synchronize do super end end |
#multi_response_nonblock ⇒ Object
40 41 42 43 44 |
# File 'lib/dalli/options.rb', line 40 def multi_response_nonblock @lock.synchronize do super end end |
#multi_response_start ⇒ Object
34 35 36 37 38 |
# File 'lib/dalli/options.rb', line 34 def multi_response_start @lock.synchronize do super end 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
56 57 58 |
# File 'lib/dalli/options.rb', line 56 def unlock! @lock.mon_exit end |