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
Refactor SynchronizationContext
to provide order and execution guarantees
#5002
Conversation
Needs further consideration. Dunno how this is supposed to work. |
`Send` is supposed to block until the work completes (and run all previous work). `Post` is supposed to fire-and-forget. Both cases need to ensure correct execution order.
I've updated the implementation to match expectations of Windows Form / WPF in the table on https://docs.microsoft.com/en-us/archive/msdn-magazine/2011/february/msdn-magazine-parallel-computing-it-s-all-about-the-synchronizationcontext. I think this is closest to what we want. Note that as a result, the I'd recommend reviewers do their own reading on the topic, the linked page above is worth a read, potentially twice over. I'll add tests (covering order of execution and inline execution constraints) once we come to an agreement. |
Is there a reason for |
I guess we have different readings for what "execute in queue order" means. It doesn't look like the WPF dispatcher preserves ordering between |
Those both seem dependent on a priority enum though. Is the Regardless, I wouldn't want to get that complex. As per the MS documentation, implementation is up to the implementation, and enforcing order isn't going to break anything. |
Put another way, I definitely feel uneasy running every single scheduled delegate immediately. |
I don't necessarily disagree. Would you be okay if it was isolated from the game thread scheduler? That would remove any uneasiness from my end. |
Yes, that would be fine |
To answer this question, it seems like the default priority is |
Tests and logic should be good to go. |
SchedulerSynchronizationContext
to run work inline when feasibleSynchronizationContext
to provide order and execution guarantees
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 don't have a huge amount of knowledge about sync contexts but this pretty much matches what I'd expect to see out of one.
One thing I'm not entirely clear on is when the game will actually use Send()
, if at all. But maybe that will become clear when I look at that part.
Co-authored-by: Bartłomiej Dach <dach.bartlomiej@gmail.com>
No description provided.