Project

General

Profile

Actions

Feature #20715

closed

`Ractor.[]` and `Ractor.[]=` to access Ractor local storage

Added by ko1 (Koichi Sasada) 4 months ago. Updated about 2 months ago.

Status:
Closed
Target version:
-
[ruby-core:119050]

Description

Trivial proposal.

Now Ractor#[]/#[]= is supported to access current ractor local storage. However, it doesn't allow to access local storage of other ractors.

Ractor.current[:foo] = 1

Ractor.new{ 
  p Ractor.main[:foo] #=> nil
}.take

So providing Ractor.[]/[]= is more reasonable.
Further more, we don't need to use Ractor#current and it is slightly faster.

Updated by Eregon (Benoit Daloze) 4 months ago

+1, makes perfect sense (IMO it would be nice to do the same for Fiber and Thread as well but out of scope of this issue).

Updated by byroot (Jean Boussier) 4 months ago

it would be nice to do the same for Fiber and Thread as well

Would also be the occasion for Thread[] to be actual thread local instead of fiber local.

Actions #3

Updated by hsbt (Hiroshi SHIBATA) 3 months ago

  • Status changed from Open to Assigned

Updated by nobu (Nobuyoshi Nakada) about 2 months ago

I'd expect that accessing other Ractors' local storages will raise an exception.

Actions #5

Updated by ko1 (Koichi Sasada) about 2 months ago

  • Status changed from Assigned to Closed

Applied in changeset git|075a102c937969c62a6798b32b3c3188df91a075.


Ractor.[] and Ractor.[]=

Ractor#[]/[]= is only for accessors to the current ractor, so that
Ractor.[]/[]= is simpler.
[Feature #20715]

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0