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.



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

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

Instance Method Details

#clearObject



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

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

#delete(tid) ⇒ Object



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

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

#dupObject



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

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

#set(tid, hash) ⇒ Object



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

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

#sizeObject



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

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