-
Notifications
You must be signed in to change notification settings - Fork 264
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
Rework /internal/queue package #1449
Merged
Merged
+93
−130
Conversation
This file contains 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
helsaawy
reviewed
Jul 7, 2022
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.
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 aRLock
would make sense
b. if we use theRLock
at the beginning ofDe
/Enqueue
to 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
MessageQueue
shouldnt be copied (cause ofclosed bool
), there a gross hack thatsync
uses to raisego vet
errors that we may want to use here
|
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 <dcanter@microsoft.com>
@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 <dcanter@microsoft.com>
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 <dcanter@microsoft.com> (cherry picked from commit 12d4cd8) Signed-off-by: Daniel Canter <dcanter@microsoft.com>
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 <dcanter@microsoft.com>
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.