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.
14 15 16 17 18 19 20 21 |
# File 'lib/infinite_tracing/worker.rb', line 14 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.
12 13 14 |
# File 'lib/infinite_tracing/worker.rb', line 12 def error @error end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/infinite_tracing/worker.rb', line 12 def name @name end |
Instance Method Details
#error? ⇒ Boolean
33 34 35 |
# File 'lib/infinite_tracing/worker.rb', line 33 def error? !!@error end |
#join(timeout = nil) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/infinite_tracing/worker.rb', line 37 def join(timeout = nil) return unless @worker_thread NewRelic::Agent.logger.debug("joining worker #{@name} thread...") @worker_thread.join(timeout) end |
#status ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/infinite_tracing/worker.rb', line 23 def status return 'error' if error? @lock.synchronize do return 'stopped' if @worker_thread.nil? @worker_thread.status || 'idle' end end |