class At_email::Threads::Thread_Queue

Constants

CLASS_DISPLAY_NAME

Attributes

threads[RW]

Public Class Methods

new() click to toggle source
Calls superclass method At_email::Core::Default::new
# File lib/at_email/threads/thread_queue.rb, line 10
def initialize
  super
  if !@properties
    return false
  end
  @threads = {}
  @properties['Display Name'] = CLASS_DISPLAY_NAME
  @properties['Max Threads'] = 2
end

Public Instance Methods

activate() click to toggle source
# File lib/at_email/threads/thread_queue.rb, line 20
def activate
  @properties['Activation Time'] = Time.now
  @properties['State'] = 'Active'
end
queue_thread(code) click to toggle source
# File lib/at_email/threads/thread_queue.rb, line 25
def queue_thread(code)
  thread_object = At_email::Tasks::TaskThread.new
  thread_id = thread_object['ID']
  @threads[thread_id] = thread_object
  @threads[thread_id].queue(code)
  return thread_id
end
start_thread(thread_id) click to toggle source
# File lib/at_email/threads/thread_queue.rb, line 33
def start_thread(thread_id)
  if get_state() === 'Active'
    @threads[thread_id].start
  else
    formatted_property = get_formatted('State')
    log_string = 'Thread cannot be started as this thread queue is not active - ' + formatted_property
    log_event('W', log_string)
  end
end
stop_thread(thread_id) click to toggle source
# File lib/at_email/threads/thread_queue.rb, line 43
def stop_thread(thread_id)
  @threads[thread_id].stop
end