Class: Sidekiq::Processor::SharedWorkerState
- Inherits:
-
Object
- Object
- Sidekiq::Processor::SharedWorkerState
- Defined in:
- lib/sidekiq/processor.rb
Overview
jruby’s Hash implementation is not threadsafe, so we wrap it in a mutex here
Instance Method Summary collapse
- #clear ⇒ Object
- #delete(tid) ⇒ Object
- #dup ⇒ Object
-
#initialize ⇒ SharedWorkerState
constructor
A new instance of SharedWorkerState.
- #set(tid, hash) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize ⇒ SharedWorkerState
Returns a new instance of SharedWorkerState.
215 216 217 218 |
# File 'lib/sidekiq/processor.rb', line 215 def initialize @worker_state = {} @lock = Mutex.new end |
Instance Method Details
#clear ⇒ Object
236 237 238 |
# File 'lib/sidekiq/processor.rb', line 236 def clear @lock.synchronize { @worker_state.clear } end |
#delete(tid) ⇒ Object
224 225 226 |
# File 'lib/sidekiq/processor.rb', line 224 def delete(tid) @lock.synchronize { @worker_state.delete(tid) } end |
#dup ⇒ Object
228 229 230 |
# File 'lib/sidekiq/processor.rb', line 228 def dup @lock.synchronize { @worker_state.dup } end |
#set(tid, hash) ⇒ Object
220 221 222 |
# File 'lib/sidekiq/processor.rb', line 220 def set(tid, hash) @lock.synchronize { @worker_state[tid] = hash } end |
#size ⇒ Object
232 233 234 |
# File 'lib/sidekiq/processor.rb', line 232 def size @lock.synchronize { @worker_state.size } end |