Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
threadpool: drop incomplete tasks on shutdown #722
threadpool: drop incomplete tasks on shutdown #722
Changes from all commits
de91466
2c746a2
2af33eb
cea901c
53b2e8d
0ea5518
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
This is just an unused field from the times before
ShutdownTrigger
so I'm removing it.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.
It seems like this should be
UnsafeCell
? I'm surprised thatCell
works. It must be becauseTask
is!Send
?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.
Actually,
Task
isSend
because it can be stolen and moved between worker threads.What is important here is that
Task
hasSync
and!Sync
parts:state
isSync
because it may be concurrently written to from multiple threads, e.g. during notification.future
is!Sync
because it's only ever used by the thread which is currently executing it.reg_worker
is!Sync
for the same reason.It seems to me that
reg_worker
can be aCell
here just fine, since it's never accessed concurrently. Is my understanding correct? Otherwise, I can switch toUnsafeCell
, it's no problem.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.
It can be safely called, it was more of a question of how to write idiomatic unsafe rust code :)
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'm very interested in the answer to that question, too... this kind of pattern occurs in plenty of places.
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.
The problem with using a
Slab
here is that the memory will grow to hold the max number of tasks that were concurrently running, but never shrink after. Slabs can't easily shrink due to their design.Do you have thoughts on this?
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.
It's hard to say for me whether that's really a problem in practice or not. This
Slab
should be pretty compact sinceArc<Task>
is just a single word. If you're worried about it, I can switch back toVec
and we can shrink the underlying buffer when it gets less than half full.