[#100689] [Ruby master Feature#17303] Make webrick to bundled gems or remove from stdlib — hsbt@...
Issue #17303 has been reported by hsbt (Hiroshi SHIBATA).
11 messages
2020/11/02
[#100852] [Ruby master Feature#17326] Add Kernel#must! to the standard library — zimmerman.jake@...
SXNzdWUgIzE3MzI2IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGpleiAoSmFrZSBaaW1tZXJtYW4pLg0K
24 messages
2020/11/14
[#100930] [Ruby master Feature#17333] Enumerable#many? — masafumi.o1988@...
Issue #17333 has been reported by okuramasafumi (Masafumi OKURA).
10 messages
2020/11/18
[#101071] [Ruby master Feature#17342] Hash#fetch_set — hunter_spawn@...
Issue #17342 has been reported by MaxLap (Maxime Lapointe).
26 messages
2020/11/25
[ruby-core:100819] [Ruby master Feature#17323] Ractor::LVar to provide ractor-local storage
From:
ko1@...
Date:
2020-11-12 18:44:48 UTC
List:
ruby-core #100819
Issue #17323 has been updated by ko1 (Koichi Sasada).
marcandre (Marc-Andre Lafortune) wrote in #note-2:
> - deep-copying the cache is probably faster than having to recalculate part of it
> - more importantly, this would probably be the wrong solution if we had `SharedHash`:
it depends on the problem. per-ractor cache is faster to access because there are no synchronization overhead.
Anyway, cache is not a good example.
I wrote it in GH thread https://github.com/ruby/ruby/pull/3762#issuecomment-726227262
> I'm not sure it is a feasible example, but we can set separate configuration between ractors.
> Another idea is to provide unshareable, but similar to global variables, such as Random::DEFAULT which is discussed on https://bugs.ruby-lang.org/issues/17322.
> We can use LVar to implement Ractor::default.
Maybe we can study with the usage of `Thread#thread_variable_get(sym)`.
but not so many https://gist.github.com/ko1/c00020a2c06dceaf9fd5d930e721651e
----------------------------------------
Feature #17323: Ractor::LVar to provide ractor-local storage
https://bugs.ruby-lang.org/issues/17323#change-88459
* Author: ko1 (Koichi Sasada)
* Status: Open
* Priority: Normal
----------------------------------------
Ruby supports thread and fiber local storage:
* `Thread#[sym]` provides *Fiber* local storage
* `Thread#thread_variable_get(sym)
These APIs can access other threads/fibers like that:
```ruby
th = Thread.new{
Thread.current.thread_variable_set(:a, 10)
}
th.join
# access from main thread to child thread
p th.thread_variable_get(:a)
```
To make Ractor local storage, this kind of feature should not be allowed to protect isolation.
This ticket propose alternative API `Ractor::LVar` that allows to provide Ractor local variable.
```ruby
LV1 = Ractor::LVar.new
p LV1.value #=> nil # default value
LV1.value = 'hello' # can set unshareable objects because LVar is ractor local.
Ractor.new do
LV1.value = 'world' # set Ractor local variable
end.take
p LV1.value #=> 'hello'
# Lvar.new can accept default_proc which should be isolated Proc.
LV2 = Ractor::LVar.new{ "x" * 4 }
p LV2.value #=> "xxxx"
LV2.value = 'yyy'
Ractor.new do
p LV2.value #=> 'xxx'
end
p LV2.value #=> 'yyy'
```
This API doesn't support accessing from other ractors.
`Ractor::LVar` is from `Ractor::TVar`, but I have no strong opinion about it.
For example, `Ractor::LocalVariable` is longer and clearer.
Implementation: https://github.com/ruby/ruby/pull/3762
--
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>