lib/stella/common.rb in stella-0.8.0.001 vs lib/stella/common.rb in stella-0.8.1.001
- old
+ new
@@ -248,27 +248,36 @@
def stop()
@force_stop = true
@dthread.join
@routine.call
+ @finally.call unless @finally.nil?
end
def stop?() @force_stop == true end
-
+
+ def stopped?() @stopped end
+
# Execute yield every FREQUENCY seconds.
def start
@dthread ||= Thread.new do
prev_ptime = Time.now
loop do
- break if Stella.abort? || stop?
+ @stopped = true and break if Stella.abort? || stop?
if (Time.now - prev_ptime).to_i >= @freq
@routine.call
prev_ptime = Time.now
end
sleep @rest
end
end
@dthread.abort_on_exception = true
end
+
+ def finally(&blk)
+ @finally = blk
+ end
end
+
+
end