From 5875fce6ce678c444456cc7eed6f28ef000dac24 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Thu, 2 Mar 2023 18:27:44 +0900 Subject: `Ractor::Selector#empty?` It returns the waiting set is empty or not. Also add Ractor::Selector's tests. --- ractor.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'ractor.rb') diff --git a/ractor.rb b/ractor.rb index 6c57d65f87..5620eeec38 100644 --- a/ractor.rb +++ b/ractor.rb @@ -428,6 +428,18 @@ class Ractor __builtin_ractor_selector_clear end + # call-seq: + # selector.empty? + # + # Returns true if the number of ractors in the waiting set at the current time is zero. + # + # Note that even if #empty? returns false, the subsequent #wait + # may raise an exception because other ractors may close the target ractors. + # + def empty? + __builtin_ractor_selector_empty_p + end + # call-seq: # selector.wait(receive: false, yield_value: yield_value, move: false) -> [ractor or symbol, value] # -- cgit v1.2.1