Class: Wurk::Processor::SharedWorkState
- Inherits:
-
Object
- Object
- Wurk::Processor::SharedWorkState
- 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
- #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.
105 106 107 108 |
# File 'lib/wurk/processor.rb', line 105 def initialize @work = {} @lock = ::Mutex.new end |
Instance Method Details
#clear ⇒ Object
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 |
#dup ⇒ Object
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 |
#size ⇒ Object
122 123 124 |
# File 'lib/wurk/processor.rb', line 122 def size @lock.synchronize { @work.size } end |