Class: Sidekiq::Processor::SharedWorkState
- Inherits:
-
Object
- Object
- Sidekiq::Processor::SharedWorkState
- 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 ⇒ SharedWorkState
constructor
A new instance of SharedWorkState.
- #set(tid, hash) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize ⇒ SharedWorkState
Returns a new instance of SharedWorkState.
255 256 257 258 |
# File 'lib/sidekiq/processor.rb', line 255 def initialize @work_state = {} @lock = Mutex.new end |
Instance Method Details
#clear ⇒ Object
276 277 278 |
# File 'lib/sidekiq/processor.rb', line 276 def clear @lock.synchronize { @work_state.clear } end |
#delete(tid) ⇒ Object
264 265 266 |
# File 'lib/sidekiq/processor.rb', line 264 def delete(tid) @lock.synchronize { @work_state.delete(tid) } end |
#dup ⇒ Object
268 269 270 |
# File 'lib/sidekiq/processor.rb', line 268 def dup @lock.synchronize { @work_state.dup } end |
#set(tid, hash) ⇒ Object
260 261 262 |
# File 'lib/sidekiq/processor.rb', line 260 def set(tid, hash) @lock.synchronize { @work_state[tid] = hash } end |
#size ⇒ Object
272 273 274 |
# File 'lib/sidekiq/processor.rb', line 272 def size @lock.synchronize { @work_state.size } end |