-
Notifications
You must be signed in to change notification settings - Fork 58
#204: Use default scheduler for worker tasks #205
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,7 @@ public AsynchronousWorker( | |
| _optionalExceptionHandler = optionalExceptionHandler; | ||
| for (int i = 0; i < workerThreadCount; ++i) | ||
| { | ||
| _workers.Add(Task.Factory.StartNew(() => Dequeue(), TaskCreationOptions.LongRunning)); | ||
| _workers.Add(Task.Factory.StartNew(() => Dequeue(), CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @George-Shaw on this codex comment about a regression test: worth adding, since this is the kind of bug that's easy to silently reintroduce later (someone "simplifies" the a minimal version could be: construct a custom do you have bandwidth to add it to this PR? if not, no worries, we'll take care of it on our end. just let us know.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, a regression test would be a good idea here. The test you describe should do the job. Unfortunately, I've recently come back from holiday to a large backlog of work, so I'm unlikely to have time to do this anytime soon. Sorry for the inconvenience!
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no worries at all, thanks for letting us know. just pushed the regression test as commit it builds a also wanted to say thanks for updating the description and commit message, the new wording reads great. ptal when you have a sec and let us know if anything looks off about the test, otherwise we'll move to get this merged.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test looks good to me. I'm impressed with how quickly you did that. I guess that's an advantage to already being familiar with the test suite... |
||
| } | ||
| } | ||
|
|
||
|
|
||
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.
@George-Shaw thanks for the fix. quick question on this codex comment: the description says workers will "always run on thread pool threads", but
TaskCreationOptions.LongRunningwithTaskScheduler.Defaultactually spins up a dedicated background thread rather than using the pool. the fix itself is still correct for the issue you're solving (keeping work off a caller-supplied scheduler like a UISynchronizationContext), it's just the wording that's a bit off.a couple things we wanted to check with you:
also, separately, the line in your description suggesting
Task.Runwould be better: agreed it reads more cleanly, butTask.Rundoesn't acceptTaskCreationOptions.LongRunning, so swapping to it would change behavior (workers would run on pool threads instead of dedicated ones, with potential pool-starvation risk at higherworkerThreadCount). probably worth either dropping that line or moving it to a "future work" note so it doesn't read as part of this PR's scope.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.
LongRunninghas on the default scheduler and that it cannot be used withTask.Run.I'll also update the commit message in a little bit.
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.
Commit message now updated to remove the reference to "thread pool threads".
I also rebased the commit on the latest master while I was at it.