ThreadParent
ThreadParent facilitates spawning threads that maintain a reference to the thread that created them.
The primary goal is to allow thread local variable lookup through the ancestor chain.
Installation
Add this line to your application's Gemfile:
gem 'thread-parent'
And then execute:
$ bundle
Or install it yourself as:
$ gem install thread-parent
Usage
Thread is extended to provide direct access to its 'parent', or the thread where the current
thread was created. It also provides a way to lookup through its ancestor chain for Thread-local variables.
require 'thread_parent'
Thread.current[:abc] = 'abc'
Thread.new do |thread|
thread.parent == Thread.main
thread[:abc]
thread.parents[:abc]
thread[:def] = 'def'
thread[:def]
thread.parents[:def]
Thread.parents[:abc]
Thread.parent == Thread.main
Thread.new do
Thread.parents[:def]
Thread.parents[:abc]
end
end
Code Status
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request