refactor!: Major code cleanup for clearer state - #27
Conversation
71902db to
6674e46
Compare
1b5cbd6 to
5800e75
Compare
| (TaskCreationOptions)TaskCreationOptions | ||
| ) | ||
| : new Task(() => currentWorker.DoWork(_reportProgress, _done), tokenSource.Token); | ||
| var currentRun = new Task<Task>( |
There was a problem hiding this comment.
No try/catch or other error handling for this task? Unobserved task exceptions 😬
There was a problem hiding this comment.
It's important that the tasks don't start within this SolveInstance.
They get started all together in PostSolveInstance
That way, it it guaranteed that a task never calls Done while we are still spinning up workers. That would break the components state tracking.
There was a problem hiding this comment.
Perhaps there's alternatives with storing Func<Task>, but for this PR I wanted to keep minimal changes
adamhathcock
left a comment
There was a problem hiding this comment.
We probably want some basic error handling and feed back. I don't think we should be delegating this to the caller, at least for cancellation exceptions.
Good clean up though, much nicer.
| (TaskCreationOptions)TaskCreationOptions | ||
| ) | ||
| : new Task(() => currentWorker.DoWork(_reportProgress, _done), tokenSource.Token); | ||
| var currentRun = new Task<Task>( |
There was a problem hiding this comment.
No try/catch or other error handling for this task? Unobserved task exceptions 😬
|
No error handling, because this component cannot really handle the errors. |
Major refactor
Code cleanup, I've tried to make the state handling clearer by wrapping the worker state in a new
Workerclass.Cleaner code around reset of state
More proper disposal logic (still not perfect)
Breaking change around
DoWorkfunction now returns aTaskobject.Non-
asyncfunction should simply return aTask.CompletedTaskasync functions can now
awaitTODO: check with Adam, we may actually prefer using an
async voidpattern here. The root task isn't awaited, so it's not like we need to keep theawaitchain... but it feels weird to have aTaskthat wraps an async void