Class: SystemTimer::ThreadTimer

Inherits:
Object
  • Object
show all
Defined in:
lib/system_timer/thread_timer.rb

Overview

Timer saving associated thread. This is needed because we trigger timers from a Ruby signal handler and Ruby signals are always delivered to main thread.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(trigger_time, thread, exception_class = nil) ⇒ ThreadTimer

Returns a new instance of ThreadTimer.



11
12
13
14
15
# File 'lib/system_timer/thread_timer.rb', line 11

def initialize(trigger_time, thread, exception_class = nil)
  @trigger_time = trigger_time
  @thread = thread
	  @exception_class = exception_class || Timeout::Error
end

Instance Attribute Details

#exception_classObject (readonly)

Returns the value of attribute exception_class.



9
10
11
# File 'lib/system_timer/thread_timer.rb', line 9

def exception_class
  @exception_class
end

#threadObject (readonly)

Returns the value of attribute thread.



9
10
11
# File 'lib/system_timer/thread_timer.rb', line 9

def thread
  @thread
end

#trigger_timeObject (readonly)

Returns the value of attribute trigger_time.



9
10
11
# File 'lib/system_timer/thread_timer.rb', line 9

def trigger_time
  @trigger_time
end

Instance Method Details

#to_sObject



17
18
19
# File 'lib/system_timer/thread_timer.rb', line 17

def to_s
  "<ThreadTimer :time => #{trigger_time}, :thread => #{thread}, :exception_class => #{exception_class}>"
end