Module: Celluloid
- Defined in:
- lib/timeout/extensions/celluloid.rb
Defined Under Namespace
Modules: TimeoutExtensions Classes: Actor, Thread
Class Method Summary collapse
-
.timeout(duration, klass = nil) ⇒ Object
Celluloid Monkey-Patch Alert!!!! I would really like to remove this but, but I first need this pull request accepted: github.com/celluloid/celluloid/pull/491.
Class Method Details
.timeout(duration, klass = nil) ⇒ Object
Celluloid Monkey-Patch Alert!!!! I would really like to remove this but, but I first need this pull request accepted: github.com/celluloid/celluloid/pull/491
These methods have kept the same functionality for quite some time, therefore are quite stable, I just moved the locations and updated/corrected the method signatures.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/timeout/extensions/celluloid.rb', line 30 def self.timeout(duration, klass = nil) bt = caller task = Task.current klass ||= TaskTimeout timers = Thread.current[:celluloid_actor].timers timer = timers.after(duration) do exception = klass.new("execution expired") exception.set_backtrace bt task.resume exception end yield ensure timer.cancel if timer end |