Class: NewRelic::Agent::InfiniteTracing::Worker
- Inherits:
-
Object
- Object
- NewRelic::Agent::InfiniteTracing::Worker
- Defined in:
- lib/infinite_tracing/worker.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(name, &job) ⇒ Worker
constructor
A new instance of Worker.
- #join(timeout = nil) ⇒ Object
- #status ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(name, &job) ⇒ Worker
Returns a new instance of Worker.
15 16 17 18 19 20 21 22 |
# File 'lib/infinite_tracing/worker.rb', line 15 def initialize(name, &job) @name = name @job = job @error = nil @worker_thread = nil @lock = Mutex.new @lock.synchronize { start_thread } end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
13 14 15 |
# File 'lib/infinite_tracing/worker.rb', line 13 def error @error end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/infinite_tracing/worker.rb', line 13 def name @name end |
Instance Method Details
#error? ⇒ Boolean
32 33 34 |
# File 'lib/infinite_tracing/worker.rb', line 32 def error? !!@error end |
#join(timeout = nil) ⇒ Object
36 37 38 39 40 |
# File 'lib/infinite_tracing/worker.rb', line 36 def join(timeout = nil) return unless @worker_thread NewRelic::Agent.logger.debug("joining worker #{@name} thread...") @worker_thread.join(timeout) end |
#status ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/infinite_tracing/worker.rb', line 24 def status return "error" if error? @lock.synchronize do return "stopped" if @worker_thread.nil? @worker_thread.status || "idle" end end |