[ruby-core:74280] [Ruby trunk Feature#3944] Add Fiber#root? method

From: nakilon@...
Date: 2016-03-11 18:32:33 UTC
List: ruby-core #74280
Issue #3944 has been updated by Victor Maslov.


For example, the Facebook Graph API server accepts POST request to calculate smth heavy and returns id of the 'async job'. Then I GET status until it's "complete" and then I GET the actual result.  
To process thousands of requests I call my method_that_gets_data from inside Fiber.new for each URL and cycle through them until they are done. Inside method_that_gets_data there are yeilds when doing the first POST and when status is not "complete", so I know when the fiber is done or I should just check another one.  
Now I want to reuse the method_that_gets_data without fibers -- to know whether to yield or to work until done I need to know if I'm running inside Fiber or not.

----------------------------------------
Feature #3944: Add Fiber#root? method
https://bugs.ruby-lang.org/issues/3944#change-57403

* Author: Mike Perham
* Status: Feedback
* Priority: Normal
* Assignee: Koichi Sasada
----------------------------------------
=begin
 Since the root fiber is treated differently than other Fibers (e.g. you can't yield from the root), code which can optionally use fibers for high-performance IO (in my case, the Mysql2 driver) needs Fiber#root? to know when it can use Fibers to execute a query versus using a standard blocking call.
=end




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next