Class: Neetodeploy::Worker
- Inherits:
-
Object
- Object
- Neetodeploy::Worker
- Defined in:
- lib/neetodeploy/autoscale/worker.rb
Instance Attribute Summary collapse
-
#mutex ⇒ Object
readonly
Returns the value of attribute mutex.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
Instance Method Summary collapse
-
#initialize ⇒ Worker
constructor
A new instance of Worker.
- #push(msg) ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize ⇒ Worker
Returns a new instance of Worker.
10 11 12 13 14 |
# File 'lib/neetodeploy/autoscale/worker.rb', line 10 def initialize @mutex = Mutex.new @queue = Queue.new end |
Instance Attribute Details
#mutex ⇒ Object (readonly)
Returns the value of attribute mutex.
8 9 10 |
# File 'lib/neetodeploy/autoscale/worker.rb', line 8 def mutex @mutex end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
8 9 10 |
# File 'lib/neetodeploy/autoscale/worker.rb', line 8 def queue @queue end |
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
8 9 10 |
# File 'lib/neetodeploy/autoscale/worker.rb', line 8 def thread @thread end |
Instance Method Details
#push(msg) ⇒ Object
16 17 18 |
# File 'lib/neetodeploy/autoscale/worker.rb', line 16 def push(msg) start && queue.push(msg) end |
#start ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/neetodeploy/autoscale/worker.rb', line 20 def start mutex.synchronize do return true if thread&.alive? @thread = Thread.new { run } end true end |