Class: Async::IO::Threads
- Inherits:
-
Object
- Object
- Async::IO::Threads
- Defined in:
- lib/async/io/threads.rb
Instance Method Summary collapse
- #async(parent: (@parent or Task.current)) ⇒ Object
-
#initialize(parent: nil) ⇒ Threads
constructor
A new instance of Threads.
Constructor Details
#initialize(parent: nil) ⇒ Threads
Returns a new instance of Threads.
28 29 30 |
# File 'lib/async/io/threads.rb', line 28 def initialize(parent: nil) @parent = parent end |
Instance Method Details
#async(parent: (@parent or Task.current)) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/async/io/threads.rb', line 33 def async(parent: (@parent or Task.current)) parent.async do thread = ::Thread.new do yield end thread.join rescue Stop if thread&.alive? thread.raise(Stop) end begin thread.join rescue Stop # Ignore. end end end |