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