From: eregontp@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:96693] [Ruby master Feature#8215] Support accessing Fiber-locals and backtraces for a Fiber
Date: Mon, 06 Jan 2020 18:22:12 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-83678.20200106182211.130f88b1aa72877e@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-8215.20130404084751@ruby-lang.org
Issue #8215 has been updated by Eregon (Benoit Daloze).
`Fiber#[]` and `Fiber#[]=` sounds fine, but what if somebody does:
`some_fiber = Fiber.new { ... }; Thread.new { some_fiber[:fiber_local] }`?
I think that should raise or not be possible.
If it would return the value, it would imply synchronization on every access to fiber locals which seems unfortunate.
By making the API `Fiber.[]`, we can avoid that entirely and have true fiber-locals, which can only be accessed by that Fiber:
```ruby
Fiber[:my_fiber_local] = 42
value = Fiber[:my_fiber_local]
# no way to access fiber locals of another Fiber
```
I think for new APIs we should take the chance to make them only possible to use correctly.
We could even finally have Fiber and Thread local in a consistent way:
```ruby
# access Fiber-local
Fiber[:my_fiber_local]
# access Thread-local
Thread[:my_thread_local]
```
----------------------------------------
Feature #8215: Support accessing Fiber-locals and backtraces for a Fiber
https://bugs.ruby-lang.org/issues/8215#change-83678
* Author: halorgium (Tim Carey-Smith)
* Status: Assigned
* Priority: Normal
* Assignee: ioquatix (Samuel Williams)
* Target version:
----------------------------------------
=begin
As part of debugging celluloid, I have been wanting to diagnose where the Fibers are running and their various locals.
I would expect the following to work.
Thread.current[:key] = "outside"
fiber = Fiber.new do
Thread.current[:key] = "inside"
Fiber.yield
end
fiber.resume
fiber[:key] == "inside" # true
fiber.backtrace # ...
I also wonder whether (({Fiber#[]})) should be implemented, so (({Fiber.current[:key]})) is possible.
For reference, here is the issue on the rubinius issue tracker: ((<"github/rubinius/rubinius/2200"|URL:https://github.com/rubinius/rubinius/issues/2200>))
=end
---Files--------------------------------
0001-cont.c-fiber-local-accessors.patch (2.94 KB)
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2020-01-06 18:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-03 23:47 [ruby-core:53974] [ruby-trunk - Feature #8215][Open] Support accessing Fiber-locals and backtraces for a Fiber halorgium (Tim Carey-Smith)
2013-04-04 12:50 ` [ruby-core:53990] [ruby-trunk - Feature #8215][Closed] " Eregon (Benoit Daloze)
2013-04-05 9:27 ` [ruby-core:54019] [ruby-trunk - Feature #8215][Open] " nobu (Nobuyoshi Nakada)
2013-04-05 11:06 ` [ruby-core:54021] [ruby-trunk - Feature #8215] " Eregon (Benoit Daloze)
2013-04-07 10:14 ` [ruby-core:54080] " halorgium (Tim Carey-Smith)
2013-04-09 7:33 ` [ruby-core:54133] " nobu (Nobuyoshi Nakada)
2013-04-16 8:03 ` [ruby-core:54329] " nobu (Nobuyoshi Nakada)
2013-04-19 6:50 ` [ruby-core:54457] " halorgium (Tim Carey-Smith)
2013-04-19 7:01 ` [ruby-core:54460] moving issues (was: [ruby-trunk - Feature #8215] Support accessing Fiber-locals and backtraces for a Fiber) "Martin J. Dürst"
2013-06-02 6:45 ` [ruby-core:55237] [ruby-trunk - Feature #8215][Assigned] Support accessing Fiber-locals and backtraces for a Fiber zzak (Zachary Scott)
2020-01-05 22:51 ` [ruby-core:96674] [Ruby master Feature#8215] " samuel
2020-01-05 22:51 ` [ruby-core:96675] " samuel
2020-01-06 18:22 ` eregontp [this message]
2020-01-06 20:50 ` [ruby-core:96694] " samuel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-83678.20200106182211.130f88b1aa72877e@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).