From: shyouhei@...
Date: 2020-11-26T22:26:14+00:00
Subject: [ruby-core:101109] [Ruby master Feature#17322] Deprecate `Random::DEFAULT` and introduce `Random.default()` method to provide Ractor-supported default random generator

Issue #17322 has been updated by shyouhei (Shyouhei Urabe).


Despite the title of this issue, ko1���s intention is to make Ractor usable, not to make Random usable.

I think there still is a room to depreciate Random::DEFAULT.  But if you want that I guess you can have a separate ticket.  I guess that should be smoother than discussing it here.

----------------------------------------
Feature #17322: Deprecate `Random::DEFAULT` and introduce `Random.default()` method to provide Ractor-supported default random generator
https://bugs.ruby-lang.org/issues/17322#change-88784

* Author: ko1 (Koichi Sasada)
* Status: Open
* Priority: Normal
----------------------------------------
`Random::DEFAULT` a default random generator used by `rand`, `srand`, `Array#shuffle` without a given random generator, and so on.

Random generators are not thread-safe, so they are not ractor safe, and they are not shareable.
So a program refer to `Random::DEFAULT` on non-main ractor, it causes an error.

To provide per-ractor default random generator, this ticket propose the `Random.default()` method which returns per-ractor random generator.
`Random::DEFAULT` is a result of `Random.default()` on main-ractor and it should be deprecated, or at least it should not be used on multi-ractor supporting apps and libraries.





-- 
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>