Skip to content

Commit f0d0c03

Browse files
committed
Ractor.main?
to return the current ractor is the main ractor. (== `Ractor.current == Ractor.main`)
1 parent c8297c3 commit f0d0c03

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ractor.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,4 +850,11 @@ def self.main
850850
rb_ractor_self(GET_VM()->ractor.main_ractor);
851851
}
852852
end
853+
854+
# return true if the current ractor is main ractor
855+
def self.main?
856+
__builtin_cexpr! %q{
857+
GET_VM()->ractor.main_ractor == rb_ec_ractor_ptr(ec)
858+
}
859+
end
853860
end

0 commit comments

Comments
 (0)