Class: Runnable

Inherits:
Object
  • Object
show all
Defined in:
lib/s3-object-processor.rb

Direct Known Subclasses

ListLister, Lister, Reporter, Worker

Instance Method Summary collapse

Instance Method Details

#joinObject



27
28
29
# File 'lib/s3-object-processor.rb', line 27

def join
	@thread.join if @thread
end

#on_finish(&callback) ⇒ Object



5
6
7
8
# File 'lib/s3-object-processor.rb', line 5

def on_finish(&callback)
	(@on_finish ||= []) << callback
	self
end

#runObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/s3-object-processor.rb', line 10

def run
	@thread = Thread.new do
		begin
			yield
		rescue Interrupt
			# ignored
		ensure
			begin
				@on_finish.each{|on_finish| on_finish.call} if @on_finish
			rescue
				# ignored
			end
		end
	end
	self
end