Class: Wurk::Processor::SharedWorkState

Inherits:
Object
  • Object
show all
Defined in:
lib/wurk/processor.rb

Overview

tid → { queue:, payload:, run_at: } for every Processor currently running a job. Read by Heartbeat each beat to publish into Redis.

Instance Method Summary collapse

Constructor Details

#initializeSharedWorkState

Returns a new instance of SharedWorkState.



105
106
107
108
# File 'lib/wurk/processor.rb', line 105

def initialize
  @work = {}
  @lock = ::Mutex.new
end

Instance Method Details

#clearObject



126
127
128
# File 'lib/wurk/processor.rb', line 126

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

#delete(tid) ⇒ Object



114
115
116
# File 'lib/wurk/processor.rb', line 114

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

#dupObject



118
119
120
# File 'lib/wurk/processor.rb', line 118

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

#set(tid, hash) ⇒ Object



110
111
112
# File 'lib/wurk/processor.rb', line 110

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

#sizeObject



122
123
124
# File 'lib/wurk/processor.rb', line 122

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