Class: Baykit::BayServer::Util::ExecutorService::Executor
- Inherits:
-
Object
- Object
- Baykit::BayServer::Util::ExecutorService::Executor
- Defined in:
- lib/baykit/bayserver/util/executor_service.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#que ⇒ Object
readonly
Returns the value of attribute que.
Instance Method Summary collapse
-
#initialize(que, id, name) ⇒ Executor
constructor
A new instance of Executor.
- #run ⇒ Object
- #shutdown ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(que, id, name) ⇒ Executor
Returns a new instance of Executor.
17 18 19 20 21 |
# File 'lib/baykit/bayserver/util/executor_service.rb', line 17 def initialize(que, id, name) @que = que @id = id @name = name end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/baykit/bayserver/util/executor_service.rb', line 14 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
15 16 17 |
# File 'lib/baykit/bayserver/util/executor_service.rb', line 15 def name @name end |
#que ⇒ Object (readonly)
Returns the value of attribute que.
13 14 15 |
# File 'lib/baykit/bayserver/util/executor_service.rb', line 13 def que @que end |
Instance Method Details
#run ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/baykit/bayserver/util/executor_service.rb', line 27 def run while true block = @que.deq if block == nil break end BayLog.debug("Start task on: %s", @name) block.call BayLog.debug("End task on: %s", @name) end end |
#shutdown ⇒ Object
39 40 41 42 |
# File 'lib/baykit/bayserver/util/executor_service.rb', line 39 def shutdown @que.pop until @que.empty? @que.enq(nil) end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/baykit/bayserver/util/executor_service.rb', line 23 def to_s @name end |