Rework /internal/queue package#1449
Merged
dcantah merged 2 commits intomicrosoft:masterfrom Jul 13, 2022
Merged
Conversation
helsaawy
reviewed
Jul 7, 2022
Contributor
helsaawy
left a comment
There was a problem hiding this comment.
A couple of thoughts:
- Would a
DequeueNoWait()be useful at all? - I kind of like the
RWMutex, for a couple reasons:
a. if we add aPeek() (any, error), then it aRLockwould make sense
b. if we use theRLockat the beginning ofDe/Enqueueto check if the queue is closed/empty, then multiple attempts to read/write can fail simultaneously instead of each waiting in turn, so a moderate optimization (though I doubt performance is currently a concern) - since
MessageQueueshouldnt be copied (cause ofclosed bool), there a gross hack thatsyncuses to raisego veterrors that we may want to use here
Contributor
Author
|
Given our use cases for this package, we don't need methods that don't block on reads if there's no value to be read. Due to this, I've removed the ReadOrWait function and did a small redesign of the methods to be more in line with standard queue method naming. * Change Read/Write/IsEmpty to Dequeue/Enqueue/Size and remove ReadOrWait. Now there is no version of Read/Dequeue that doesn't block if the queue is empty. * Fix up tests to be in line with this removal of the non-blocking read and simplified most of the tests. Signed-off-by: Daniel Canter <[email protected]>
Contributor
Author
|
@helsaawy I just stuck with rwmutex as we can use it for Size check at least |
helsaawy
approved these changes
Jul 7, 2022
anmaxvl
reviewed
Jul 12, 2022
* Remove ErrQueueEmpty as it's not returned anywhere anymore. * Add test for dequeue explicitly blocking when empty. Signed-off-by: Daniel Canter <[email protected]>
anmaxvl
approved these changes
Jul 13, 2022
dcantah
added a commit
to dcantah/hcsshim
that referenced
this pull request
Jul 21, 2022
* Rework /internal/queue package Given our use cases for this package, we don't need methods that don't block on reads if there's no value to be read. Due to this, I've removed the ReadOrWait function and did a small redesign of the methods to be more in line with standard queue method naming. * Change Read/Write/IsEmpty to Dequeue/Enqueue/Size and remove ReadOrWait. Now there is no version of Read/Dequeue that doesn't block if the queue is empty. * Fix up tests to be in line with this removal of the non-blocking read and simplified most of the tests. Signed-off-by: Daniel Canter <[email protected]> (cherry picked from commit 12d4cd8) Signed-off-by: Daniel Canter <[email protected]>
princepereira
pushed a commit
to princepereira/hcsshim
that referenced
this pull request
Aug 29, 2024
* Rework /internal/queue package Given our use cases for this package, we don't need methods that don't block on reads if there's no value to be read. Due to this, I've removed the ReadOrWait function and did a small redesign of the methods to be more in line with standard queue method naming. * Change Read/Write/IsEmpty to Dequeue/Enqueue/Size and remove ReadOrWait. Now there is no version of Read/Dequeue that doesn't block if the queue is empty. * Fix up tests to be in line with this removal of the non-blocking read and simplified most of the tests. Signed-off-by: Daniel Canter <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Given our use cases for this package, we don't need methods that don't block
on reads if there's no value to be read. Due to this, I've removed the
ReadOrWait function and did a small redesign of the methods to be more
in line with standard queue method naming.
Now there is no version of Read/Dequeue that doesn't block if the queue
is empty.
and simplified most of the tests.