No commit activity in last 3 years
No release in over 3 years
Ruby's threads have no access to their root fibers. This little gem adds: - Thread#root_fiber - Fiber.root - Fiber#root? (also aliased as #root_fiber?)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.12
~> 10.0
~> 3.0
 Project Readme

ThreadRootFiber

Ruby's threads have no access to their root fibers. This little gem adds:

  • Thread#root_fiber
  • Fiber.root
  • Fiber#root? (also aliased as #root_fiber?)

Installation

Add this line to your application's Gemfile:

gem 'thread_root_fiber'

And then execute:

$ bundle

Or install it yourself as:

$ gem install thread_root_fiber

Usage

Thread#root_fiber:

Thread.main.root_fiber == Fiber.current # => true
Thread.main.root_fiber != Thread.new{ Fiber.current }.value # => true

thread = Thread.new{ Fiber.current }
thread.root_fiber == thread.value # => true
thread.root_fiber != Fiber.current # => true

Fiber.root:

Fiber.root == Fiber.current # => true
Fiber.root != Thread.new{ Fiber.current }.value # => true

thread = Thread.new{ Fiber.root }
thread.value == thread.root_fiber # => true
thread.value != Fiber.root # => true

Fiber#root?:

Fiber.current.root? # => true
Fiber.new.root? # => false

Thread.new{ Fiber.current.root? }.value # => true
Thread.new{ Fiber.new.root? }.value # => false

License

The gem is available as open source under the terms of the MIT License.