Class: Sidekiq::Processor::SharedWorkerState

Inherits:
Object
  • Object
show all
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

Constructor Details

#initializeSharedWorkerState

Returns a new instance of SharedWorkerState.


220
221
222
223
# File 'lib/sidekiq/processor.rb', line 220

def initialize
  @worker_state = {}
  @lock = Mutex.new
end

Instance Method Details

#clearObject


241
242
243
# File 'lib/sidekiq/processor.rb', line 241

def clear
  @lock.synchronize { @worker_state.clear }
end

#delete(tid) ⇒ Object


229
230
231
# File 'lib/sidekiq/processor.rb', line 229

def delete(tid)
  @lock.synchronize { @worker_state.delete(tid) }
end

#dupObject


233
234
235
# File 'lib/sidekiq/processor.rb', line 233

def dup
  @lock.synchronize { @worker_state.dup }
end

#set(tid, hash) ⇒ Object


225
226
227
# File 'lib/sidekiq/processor.rb', line 225

def set(tid, hash)
  @lock.synchronize { @worker_state[tid] = hash }
end

#sizeObject


237
238
239
# File 'lib/sidekiq/processor.rb', line 237

def size
  @lock.synchronize { @worker_state.size }
end