-
Notifications
You must be signed in to change notification settings - Fork 10
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
Thread spawn is needlessly unergonomic #99
Comments
It won't be completely trivial to get rid of the need to make R a &mut, as we can only pass in a pointer to the thread callback. We could do some pointer arithmetic, squish the moved R into the stack and let RIOT work with the remainder of the stack (RIOT will do its own alignment shenanigans in there anyway) … not pretty though. Also because the thread can never really free/use that space. It'd be neat if we could pass it into the nascent function the same way a call-by-value would go in, but that'd be architecture specific. |
If we already touch spawn, we could just already make it so that it zombifies the thread at the end, and sets a result value (possibly inside that space that was set aside for the arguments inside an enum StartAguments(R), Result(R2). Could even have a Paniced() variant if we like. Control of that memory is with the threads module, so any spurious zombification would be detectable by the start arguments still being in there. (No point in moving them out -- we've used their size already, let's call them as &mut if we can do that with a FnOnce). Some const optimization, and it'll be almost the same produced code if all involved is () or pointer sized. |
This is related to #40 and possibly best fixed in one go. |
Also, #24 could be done in the same go as well. |
Major downsides are:
A builder pattern could probably replace the single spawn function.
The text was updated successfully, but these errors were encountered: