Repository navigation
Conversation
- Windows: return false when SleepConditionVariableCS times out instead of always returning true. - Clamp timeouts to [0, 1e9] seconds, treating NaN as 0. A negative timeout used to become an almost infinite wait on Windows, and on POSIX timeouts above INT_MAX seconds overflowed and timed out immediately. - Compute the POSIX deadline with 64-bit integers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Va4FXDYWEo4mt53psuM5hu
hl uses the existing `condition_timed_wait` native and clamps the timeout itself, because older runtimes don't. CI builds the HashLink branch with the native fixes until HaxeFoundation/hashlink#1008 is merged. neko uses the new `cond_timed_wait` primitive when it is available (HaxeFoundation/neko#336), and otherwise polls with growing sleeps, using a counter that `signal` and `broadcast` increment to detect notifications. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Va4FXDYWEo4mt53psuM5hu
|
The job ran on the I didn't find an existing fix, so I've left it out of this PR. There are two options, and both are workflow changes:
Generated by Claude Code |
|
#1009 has been merged, please update the branch (if you're still watching...)! |
|
Merged Generated by Claude Code |
|
Also, I am always watching. 👀 Generated by Claude Code |
|
The In the Generated by Claude Code |
SleepConditionVariableCS takes a DWORD of milliseconds, so waits of more than about 49.7 days are capped. A capped wait that runs out had not reached the requested timeout, so return true like a spurious wakeup instead of false, which means that the timeout expired. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Va4FXDYWEo4mt53psuM5hu
|
Please merge development again! |
|
Merged Generated by Claude Code |
|
The current change seems good to me. Claude analysis point out 2 additional points which seems valid for me too, please check:
|
I'll check that, might be legit.
Yes but I don't want to deal with this here. Let's make one function that is implemented properly and then use it as a reference for the others as a follow-up. |
The Windows timed wait returned true for every error other than ERROR_TIMEOUT, while the POSIX path returns false for any error. Such errors are misuse that should not occur, and returning true would make a predicate loop spin on a persistent error, so return false like on POSIX. Only a capped wait that runs out still counts as a spurious wakeup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Va4FXDYWEo4mt53psuM5hu
|
Thanks for the review, @yuxiaomao. The first point was real, and it's fixed in 3876c8d: return ok || (capped && err == ERROR_TIMEOUT);Windows now returns On the second point, I'm leaving Generated by Claude Code |
|
Seems good to me, please feel free to merge. |
hl_condition_timed_waitwill back the newsys.thread.Condition.wait(?timeout:Float):Boolin HaxeFoundation/haxe#13109. Its result must befalseexactly when the timeout expired. This PR fixes three problems:trueand ignored the result ofSleepConditionVariableCS. It now returnsfalsewhen the wait fails withERROR_TIMEOUT.[0, 1e9]seconds, and NaN counts as 0. Before, a negative timeout cast toDWORDbecame an almost infinite wait on Windows. On POSIX, a timeout aboveINT_MAXseconds overflowed theintconversion, so the wait timed out immediately.The
!HL_THREADSbranch and the function signature are unchanged.Testing
make libhl.sobuilds with no warnings inthread.c.libhl.soon Linux, before and after the change:0.1s, no signalfalseafter 0.1 sfalseafter 0.1 s0,-1,NaN,-1e300falseat oncefalseat once1.9999999sfalseafter 2.0 sfalseafter 2.0 s1e12s, signalled after 0.1 sfalseat once (overflow)trueafter 0.1 sGenerated by Claude Code