Issue #17418 has been updated by ko1 (Koichi Sasada).


`Thread.main` is provided, so I think there is no problem to introduce `Ractor.main`.
If we find an issue about it, consider to remove it.

----------------------------------------
Feature #17418: Add `Ractor.main?` and `Ractor.main`
https://bugs.ruby-lang.org/issues/17418#change-89394

* Author: marcandre (Marc-Andre Lafortune)
* Status: Closed
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
----------------------------------------
Since main Ractor is special, it seems useful to have an easy way to check if the current ractor is the main ractor.

```ruby
Ractor.main? # => true
Ractor.new { Ractor.main? }.take # => false
```

As far as I know, a gem could be loaded from a non-main Ractor so there is no reliable way for a gem to know the main Ractor (except than trying to do something that is not allowed)

We might as well add `Ractor.main` to return the main Ractor (probably less useful though).



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