lib/textbringer/utils.rb in textbringer-0.3.0 vs lib/textbringer/utils.rb in textbringer-0.3.1

- old
+ new

@@ -52,37 +52,41 @@ def background Thread.start do begin yield rescue Exception => e - next_tick do + foreground do raise e end end end end - def next_tick(&block) + def foreground(&block) Controller.current.next_tick(&block) end - def next_tick! + alias next_tick foreground + + def foreground! q = Queue.new - next_tick do + foreground do begin result = yield q.push([:ok, result]) rescue Exception => e q.push([:error, e]) end end status, value = q.pop if status == :error - raise value + raise value else value end end + + alias next_tick! foreground! def read_event Controller.current.read_event end