Class: At_email::Tasks::TaskThread

Inherits:
Core::Default show all
Defined in:
lib/at_email/threads/thread_queue.rb

Constant Summary collapse

CLASS_DISPLAY_NAME =
'Thread'

Instance Attribute Summary collapse

Attributes inherited from Core::Default

#properties

Instance Method Summary collapse

Methods inherited from Core::Default

#get, #get_formatted, #get_state, #set_state

Constructor Details

#initializeTaskThread

Returns a new instance of TaskThread.



55
56
57
58
59
60
61
# File 'lib/at_email/threads/thread_queue.rb', line 55

def initialize
  super
  if !@properties
    return false
  end
  @properties['Display Name'] = CLASS_DISPLAY_NAME
end

Instance Attribute Details

#thread_refObject

Returns the value of attribute thread_ref.



53
54
55
# File 'lib/at_email/threads/thread_queue.rb', line 53

def thread_ref
  @thread_ref
end

Instance Method Details

#queue(code) ⇒ Object



63
64
65
66
67
68
69
70
71
72
# File 'lib/at_email/threads/thread_queue.rb', line 63

def queue(code)
  log_string = 'Queueing'
  log_event('D', event_data)
  set('Queue Time', Time.now)
  Thread.abort_on_exception = true
  @thread_ref = Thread.new do
    sleep 0.1
    code
  end
end

#startObject



74
75
76
# File 'lib/at_email/threads/thread_queue.rb', line 74

def start
  @properties['Start Time'] = Time.now
end

#stopObject



78
79
80
81
# File 'lib/at_email/threads/thread_queue.rb', line 78

def stop
  @properties['Stop Time'] = Time.now
  Thread.kill(@thread_ref)
end