Project

General

Profile

Actions

Feature #10344

closed

[PATCH] Implement Fiber#raise

Added by nome (Knut Franke) about 10 years ago. Updated about 5 years ago.

Status:
Closed
Target version:
[ruby-core:65537]

Description

While it is possible to implement this in pure Ruby (by wrapping Fiber.yield and Fiber#resume), this feels like a low-level feature that ought to be provided out of the box. Also, the C implementation is more straight-forward, and more efficient. Unfortunately, it is not quite possible to implement this as a C extension module (without resorting to wrappers again); cf. the change to make_passing_arg().

Example usage:

fib = Fiber.new do
  counter = 0
  loop { counter += Fiber.yield }
  counter
end
fib.resume
fib.resume 10
fib.resume 100
fib.raise StopIteration # => 110

Files

0001-Implement-Fiber-raise.patch (4.12 KB) 0001-Implement-Fiber-raise.patch nome (Knut Franke), 10/09/2014 12:19 AM
0001-Implement-Fiber-raise.patch (3.51 KB) 0001-Implement-Fiber-raise.patch updated patch with some doc corrections nome (Knut Franke), 10/18/2014 01:16 PM
0001-Implement-Fiber-raise-in-ext-fiber.patch (3.6 KB) 0001-Implement-Fiber-raise-in-ext-fiber.patch variant adding Fiber#raise only in ext/fiber nome (Knut Franke), 10/18/2014 01:16 PM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #595: Fiber ignores ensure clauseClosedioquatix (Samuel Williams)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0