From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id DB2F417DC1F0 for ; Sat, 18 Oct 2014 23:11:08 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 1C784B5D8DA for ; Sat, 18 Oct 2014 22:56:16 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (localhost.nagaokaut.ac.jp [127.0.0.1]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id E099097A839 for ; Sat, 18 Oct 2014 22:56:18 +0900 (JST) X-Virus-Scanned: amavisd-new at nagaokaut.ac.jp Authentication-Results: funfun.nagaokaut.ac.jp (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=sendgrid.me Received: from funfun.nagaokaut.ac.jp ([127.0.0.1]) by funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id r7HSY2k-eUz3 for ; Sat, 18 Oct 2014 22:56:18 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 9106597A827 for ; Sat, 18 Oct 2014 22:56:18 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id A511395243E for ; Sat, 18 Oct 2014 22:56:15 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 316A6120493; Sat, 18 Oct 2014 22:55:59 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o10.shared.sendgrid.net (o10.shared.sendgrid.net [173.193.132.135]) by neon.ruby-lang.org (Postfix) with ESMTPS id 37615120472 for ; Sat, 18 Oct 2014 22:55:55 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=gmFPbkrGZd6VjSoXcjXNtFEi1l0=; b=nWAZcsQMAGPqHy1INR ZjPZvMKTulI4yPYhWnkmx3yxb0d0BYiz/yA0hNF/xNzpQylZ0P1576PK6WFS/aXl ZRptTxkneaqZNHuaDzu3xa56Vo+cxSTSCpbSMqwdPUtNSJ3rGDdm02m2FNtdQCHI EEtRSh8c0fkmyov1oPk5kW6fY= Received: by filter0225p1mdw1.sendgrid.net with SMTP id filter0225p1mdw1.4691.544271673 2014-10-18 13:55:52.407976288 +0000 UTC Received: from herokuapp.com (ec2-54-205-206-208.compute-1.amazonaws.com [54.205.206.208]) by ismtpd-034 (SG) with ESMTP id 149238aff5b.4c2c.3ab2f Sat, 18 Oct 2014 13:55:52 +0000 (UTC) Date: Sat, 18 Oct 2014 13:55:51 +0000 From: Knut.Franke@gmx.de To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 40102 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 10344 X-Redmine-Issue-Author: nome X-Redmine-Sender: nome X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: OOF Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS4RiZqQ5yojJ052JPGWSXOnwl/4+U0gcakHqUIM2+dGHf5JdixdXl9AwxD8bSf0AUM/hDL7ep9HplCHyC21YxsVA/LVbmJ4cIZc679oPfX1whtScfIIrhH0gfbK0g+tz7Q= X-ML-Name: ruby-core X-Mail-Count: 65782 Subject: [ruby-core:65782] [ruby-trunk - Feature #10344] [PATCH] Implement Fiber#raise X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #10344 has been updated by Knut Franke. File 0001-Implement-Fiber-raise.patch added File 0001-Implement-Fiber-raise-in-ext-fiber.patch added > I understand this feature helps some libraries. But I can't understand why it is important. Without Fiber#raise, libraries need to use some rather inelegant and inefficient workarounds (wrapping or tagging exceptions, wrapping Fiber.yield etc). Also, having Thread#raise arguably leads one to expect the same functionality in Fiber. I'm not sure whether the feature qualifies as "important", but I still think it is worth including. > Basically, I want to recommend strongly that using Fiber as semi-croutine, ristricted feature. I think [Consumer](http://nome.github.io/coroutines/Consumer.html) is an example of a semi-coroutine (in the sense that it uses Fiber.yield, not Fiber#transfer) that benefits from having Fiber#raise. > At least, such feature should be located at ext/fiber. I disagree, because the feature is applicable to the restricted (semi-coroutine) fibers available without requiring 'fiber', and indeed implementable on top of them. Nevertheless, I've attached a variant of the patch which adds the method only in ext/fiber (as a compromise solution). ---------------------------------------- Feature #10344: [PATCH] Implement Fiber#raise https://bugs.ruby-lang.org/issues/10344#change-49518 * Author: Knut Franke * Status: Open * Priority: Normal * Assignee: * Category: * Target version: ---------------------------------------- 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 (3.51 KB) 0001-Implement-Fiber-raise-in-ext-fiber.patch (3.6 KB) -- https://bugs.ruby-lang.org/