Class: RestCore::ThreadPool::Task

Inherits:
Struct
  • Object
show all
Defined in:
lib/rest-core/thread_pool.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cancelledObject

Returns the value of attribute cancelled

Returns:

  • (Object)

    the current value of cancelled



43
44
45
# File 'lib/rest-core/thread_pool.rb', line 43

def cancelled
  @cancelled
end

#jobObject

Returns the value of attribute job

Returns:

  • (Object)

    the current value of job



43
44
45
# File 'lib/rest-core/thread_pool.rb', line 43

def job
  @job
end

#mutexObject

Returns the value of attribute mutex

Returns:

  • (Object)

    the current value of mutex



43
44
45
# File 'lib/rest-core/thread_pool.rb', line 43

def mutex
  @mutex
end

#threadObject

Returns the value of attribute thread

Returns:

  • (Object)

    the current value of thread



43
44
45
# File 'lib/rest-core/thread_pool.rb', line 43

def thread
  @thread
end

Instance Method Details

#call(working_thread) ⇒ Object

this should never fail



45
46
47
48
49
50
51
52
# File 'lib/rest-core/thread_pool.rb', line 45

def call working_thread
  mutex.synchronize do
    return if cancelled
    self.thread = working_thread
  end
  job.call
  true
end

#cancelObject



54
55
56
# File 'lib/rest-core/thread_pool.rb', line 54

def cancel
  self.cancelled = true
end