-
Notifications
You must be signed in to change notification settings - Fork 816
Add StartImmediate
to MailboxProcessor
#14931
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
Add StartImmediate
to MailboxProcessor
#14931
Conversation
ddfc233
to
673d6fa
Compare
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.
I've left a self-review asking some questions that I have regarding general development, a typo in an existing test message, and primarily regarding the idea and implementation of this feature.
tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/MailboxProcessorType.fs
Show resolved
Hide resolved
tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/MailboxProcessorType.fs
Show resolved
Hide resolved
tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/MailboxProcessorType.fs
Outdated
Show resolved
Hide resolved
Converting to draft for now. Let us know when you feel like it's ready for review. |
It is ready for review, which is why I converted it from draft to ready for review a week or two ago. I have been waiting for review and was planning on pinging on it today. The feature is implemented, has a test, and I added the signatures and documentation in the |
@bmitc alright, I will take a look on this tomorrow - thanks! |
Sounds good! Thank you! |
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.
I am up for taking this in. I understand that the usage is limited but the API is clean, the docs and tests are fine as well.
Thanks for this!
Thanks all for the help, discussion, review, and merge! 🎉 |
* Add `StartImmediate` static and instance members to `MailboxProcessor` * Remove unused `Microsoft.FSharp.Collections` declaration * Add test for `MailboxProcessor.StartImmediate` * Rename test to corrected, intended name and "fix" test * Update baseline tests * Slight update to documentation * Fix baseline tests file * Add additional commentary to test
F# language suggestion: fsharp/fslang-suggestions#997
Original PR by @xloggr: #11515
This PR implements both a static and instance
StartImmediate
method toMailboxProcessor
to start aMailboxProcessor
on the current thread. Normally,Start
will start theMailboxProcessor
on the thread pool, but theStartImmediate
method ensures that theMailboxProcessor
starts on the same thread as the one that calls it. Effectively,MailboxProcessor.Start
andMailboxProcessor.StartImmediate
map toAsync.Start
andAsync.StartImmediate
, respectively.This is useful for situations in which you want to force the
MailboxProcessor
to start on a given thread or even run on a single thread throughout its lifetime. For example, aMailboxProcessor
may be desired to wrap some unmanaged state, such as a window or some communication session that is not thread safe, and this is not currently possible withMailboxProcessor.Start
. To start aMailboxProcessor
on a specific thread, simply create that thread and then callMailboxProcessor.StartImmediate
on it.Thanks goes to @xloggr for the original suggestion and PR! This PR basically just takes that PR and adds a test and the documentation for
StartImmediate
.