Class: TingYun::Agent::Threading::AgentThread
- Inherits:
-
Object
- Object
- TingYun::Agent::Threading::AgentThread
- Defined in:
- lib/ting_yun/agent/threading/agent_thread.rb
Class Method Summary collapse
- .backing_thread_class ⇒ Object
- .backing_thread_class=(clazz) ⇒ Object
- .create(label, &blk) ⇒ Object
-
.list ⇒ Object
Simplifies testing if we don’t directly use ::Thread.list, so keep the accessor for it here on AgentThread to use and stub.
Class Method Details
.backing_thread_class ⇒ Object
39 40 41 |
# File 'lib/ting_yun/agent/threading/agent_thread.rb', line 39 def self.backing_thread_class @backing_thread_class end |
.backing_thread_class=(clazz) ⇒ Object
43 44 45 |
# File 'lib/ting_yun/agent/threading/agent_thread.rb', line 43 def self.backing_thread_class=(clazz) @backing_thread_class = clazz end |
.create(label, &blk) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ting_yun/agent/threading/agent_thread.rb', line 9 def self.create(label, &blk) TingYun::Agent.logger.debug("Creating Ting Yun thread: #{label}") wrapped_blk = Proc.new do begin blk.call rescue => e TingYun::Agent.logger.error("Thread #{label} exited with error", e) rescue Exception => e TingYun::Agent.logger.error("Thread #{label} exited with exception. Re-raising in case of interupt.", e) raise ensure TingYun::Agent.logger.debug("Exiting TingYun thread: #{label}") end end thread = backing_thread_class.new(&wrapped_blk) thread[:TingYun_label] = label thread end |
.list ⇒ Object
Simplifies testing if we don’t directly use ::Thread.list, so keep the accessor for it here on AgentThread to use and stub.
31 32 33 |
# File 'lib/ting_yun/agent/threading/agent_thread.rb', line 31 def self.list backing_thread_class.list end |