Method: Thread::Pool::Task#execute

Defined in:
lib/thread/pool.rb

#executeObject

Execute the task.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/thread/pool.rb', line 57

def execute
	return if terminated? || running? || finished?

	@thread     = Thread.current
	@running    = true
	@started_at = Time.now

	pool.__send__ :wake_up_timeout

	begin
		@result = @block.call(*@arguments)
	rescue Exception => reason
		if reason.is_a? Timeout
			@timedout = true
		elsif reason.is_a? Asked
			return
		else
			@exception = reason
			raise @exception if Thread::Pool.abort_on_exception
		end
	end

	@running  = false
	@finished = true
	@thread   = nil
end