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



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

def cancelled
  @cancelled
end

#jobObject

Returns the value of attribute job

Returns:

  • (Object)

    the current value of job



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

def job
  @job
end

#mutexObject

Returns the value of attribute mutex

Returns:

  • (Object)

    the current value of mutex



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

def mutex
  @mutex
end

#threadObject

Returns the value of attribute thread

Returns:

  • (Object)

    the current value of thread



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

def thread
  @thread
end

Instance Method Details

#call(working_thread) ⇒ Object

this should never fail



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

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

#cancelObject



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

def cancel
  self.cancelled = true
end