Repository navigation
Mutex#sleep and ConditionVariable#wait take a Rational, a BigDecimal or a long as their timeout - #55
Merged
Merged
Conversation
…or a long as their timeout MRI turns a timeout that is not an Integer or a Float into an interval through divmod(1): the whole seconds through #to_int, the fraction times 1_000_000_000 as nanoseconds; an object without a #divmod that answers an Array is "can't convert X into time interval". IronRuby only took an int or a double, so a Rational or a BigDecimal was a TypeError - and so was any Integer past 32 bits, which IronRuby holds as a long (m.sleep(2**40) raised instead of sleeping). A Bignum is MRI's RangeError only when it does not fit a long. Initializers.Generated.cs regenerated with ClassInitGenerator: the two signatures only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 52 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@sholden's fork PR sholden#7, carried over. Its fork branch
fix/sleep-interval-divmodsat onfix/condvar-wait, which is merged here as #42, so the branch can't be opened as is. This branch is sholden's one new commit (13c727a), cherry-picked onto master without conflicts and with sholden still the author. Nothing else changed.Checked on this branch (Debug, net8.0, Linux):
regen-initializers.shleavesInitializers.Generated.csexactly as committed.spec/core/mutex: 35 examples, 0 failures.spec/core/conditionvariable: 11 examples, 0 failures.Util/condvar-matrix.rbprints exactly what CRuby 4.0.6 prints (49 lines).The description below is sholden's. Bare PR numbers that were fork-local now point at sholden/ironruby, or at the upstream PR where one exists.
Stacked on #42. It builds on the shared
RubyMutex.ToSleepSecondsconversion added there.MRI converts a timeout that isn't an Integer or a Float through
divmod(1). The whole seconds go throughto_int, and the fraction is multiplied by 1_000_000_000 to give nanoseconds. Anything without a#divmodthat returns an Array raises "can't convert X into time interval". IronRuby accepted only an int or a double, so these raised TypeError:m.sleep(Rational(1, 100))andcv.wait(m, BigDecimal("0.01")), which work in MRI.m.sleep(2**40), which MRI sleeps on. IronRuby stores an Integer past 32 bits as a CLRlong, and the conversion didn't handle that type.A Bignum now raises MRI's RangeError only when it doesn't fit a long.
Initializers.Generated.cswas regenerated with ClassInitGenerator, and the regenerated file differs only in the two changed signatures (8 lines).Testing (Linux, net10.0)
Util/condvar-matrix.rbgains Rational, BigDecimal, custom#divmod, Complex, Object and2**40cases, and its output still matches CRuby.Thread#killfiber flake that predates this branch (see ConditionVariable#wait: no stale waiter after a failed wait, no lost signal at a timeout, MRI's timeout errors #42).Still different from MRI (not in this PR)
[nil, 0]from#divmodreports IronRuby's generic "no implicit conversion of nil into Integer" (MRI: "from nil to integer"). NoMethodError messages use IronRuby's backtick quoting.divmod→[0, -0.05]) raises ArgumentError here. MRI blocks forever.🤖 Generated with Claude Code