-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement multithreading primitives on Windows #11647
Implement multithreading primitives on Windows #11647
Conversation
src/crystal/system/win32/thread.cr
Outdated
thrdaddr: Pointer(LibC::UInt).null) | ||
|
||
if @th.null? | ||
raise RuntimeError.from_errno("_beginthreadex") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, raising on null both here and in beginthreadex
seems a bit redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Windows job is failing, can you run tests locally?
src/crystal/system/win32/thread.cr
Outdated
thrdaddr: Pointer(LibC::UInt).null) | ||
|
||
if @th.null? | ||
raise RuntimeError.from_errno("_beginthreadex") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed.
I cannot reproduce the CI failure locally; the same |
It seems Windows CI is working again, all that's left is fixing the WASI one. |
Co-authored-by: Johannes Müller <[email protected]>
After countless pushes I have identified that |
This enables the fiber-safe `Mutex` on Windows and removes the stub implementation. It is mostly unrelated to [`Thread::Mutex`](#11647). The standard library uses `Mutex` in `Log::SyncDispatcher`; it does not seem to break. (On the other hand, the specs for `Log::AsyncDispatcher` require non-blocking pipes, which are not available yet.)
FTR: This needed work because CI previously failed, despite working locally. Now CI was green and I considered it ready to be merged. |
Adds Win32 bindings for
Thread
,Thread::Mutex
, andThread::ConditionVariable
. They represent system threads, so they should work independently from concurrency features, even without-Dpreview_mt
. (Why aren't they namespaced underCrystal::System
if they are internal platform-dependent types...?)Related: #5430