-
Notifications
You must be signed in to change notification settings - Fork 830
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
bmitc
left a comment
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
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! |
psfinaki
left a comment
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! 🎉 |
F# language suggestion: fsharp/fslang-suggestions#997
Original PR by @xloggr: #11515
This PR implements both a static and instance
StartImmediatemethod toMailboxProcessorto start aMailboxProcessoron the current thread. Normally,Startwill start theMailboxProcessoron the thread pool, but theStartImmediatemethod ensures that theMailboxProcessorstarts on the same thread as the one that calls it. Effectively,MailboxProcessor.StartandMailboxProcessor.StartImmediatemap toAsync.StartandAsync.StartImmediate, respectively.This is useful for situations in which you want to force the
MailboxProcessorto start on a given thread or even run on a single thread throughout its lifetime. For example, aMailboxProcessormay 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 aMailboxProcessoron a specific thread, simply create that thread and then callMailboxProcessor.StartImmediateon 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.