diff options
author | Koichi Sasada <[email protected]> | 2023-03-02 18:27:44 +0900 |
---|---|---|
committer | Koichi Sasada <[email protected]> | 2023-03-03 00:08:02 +0900 |
commit | 5875fce6ce678c444456cc7eed6f28ef000dac24 (patch) | |
tree | d18dce5e9da1c5991b154774a579cd0918a7cef5 /ractor.rb | |
parent | 5f3c7ac19674b822c72e09e40cfb58fc71ac501e (diff) |
`Ractor::Selector#empty?`
It returns the waiting set is empty or not.
Also add Ractor::Selector's tests.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7417
Diffstat (limited to 'ractor.rb')
-rw-r--r-- | ractor.rb | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -429,6 +429,18 @@ class Ractor 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 <tt>#empty?</tt> returns false, the subsequent <tt>#wait</tt> + # 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] # # Waits Ractor events. It is lighter than Ractor.select() for many ractors. |