Project

General

Profile

Actions

Feature #17418

closed

Add `Ractor.main?` and `Ractor.main`

Added by marcandre (Marc-Andre Lafortune) over 3 years ago. Updated over 3 years ago.

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

Description

Since main Ractor is special, it seems useful to have an easy way to check if the current ractor is the main ractor.

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

Actions #1

Updated by marcandre (Marc-Andre Lafortune) over 3 years ago

  • Subject changed from Add `Ractor.main` and `Ractor.main?` to Add `Ractor.main?` and `Ractor.main`
Actions #2

Updated by ko1 (Koichi Sasada) over 3 years ago

  • Status changed from Open to Closed

Applied in changeset git|d0e4ccbefcdd6032d0ae70bc54c9a4fb55d92576.


add Ractor.main

It returns main Ractor, like Thread.main.
[Feature #17418]

Updated by ko1 (Koichi Sasada) over 3 years ago

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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0