-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add queue module #621
Add queue module #621
Conversation
Signed-off-by: Brian Downs <brian.downs@gmail.com>
Signed-off-by: Brian Downs <brian.downs@gmail.com>
Not really sure why CI is failing. Seems to exit without a message. Runs fine locally. |
Signed-off-by: Brian Downs <brian.downs@gmail.com>
Seems like the tests are failing for me locally, will try see what I can find |
Fixed the segfault but it seems some of the tests are failing / some memory isn't being cleared up, will continue looking |
That's really annoying I'm not seeing that on my local. I'm happy to pull down the segfault fix and keep troubleshooting. |
Some comments as well about the actual API - I think providing a queue size could probably be optional and we resize it under the hood for the user (similar to how lists work) - what do you think? I would probably also expect |
Signed-off-by: Brian Downs <brian.downs@gmail.com>
Signed-off-by: Brian Downs <brian.downs@gmail.com>
Signed-off-by: Brian Downs <brian.downs@gmail.com>
Signed-off-by: Brian Downs <brian.downs@gmail.com>
Signed-off-by: Brian Downs <brian.downs@gmail.com>
Do we need to account for different architectures in tests? I'm seeing some really weird things in CI that don't quite make sense. |
Sorry somehow completely missed this comment? The tests for a queue module shouldn't need to be different per architecture no, it would only be when we use an architecture specific include I would have imagined. Are you meaning the failing tests in CI? |
Yeah. Not sure where those errors are coming from. Of course, it works locally. :) Probably something dumb. |
That should be them passing now @briandowns, was just missing the ->capacity initialiser! I'm curious too - 99% of the time I would imagine the end user not actually caring about the initial capacity size of the queue, so for this reason I suggest we:
Thoughts? |
Dig it. I'll get on it this evening. I don't know why this was working for me. Thank you! |
That's all good! Also seem to be getting some strange behaviour in the REPL ;(
I'll do some digging into this Update: Ah I see, |
src/optionals/queue.c
Outdated
if (queue->count < queue->capacity) { | ||
int oldCapacity = queue->capacity; | ||
queue->capacity = SHRINK_CAPACITY(oldCapacity); | ||
queue->dq = SHRINK_ARRAY(vm, queue->dq, Value, oldCapacity, queue->capacity); | ||
} | ||
|
||
return newResultSuccess(vm, data); |
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.
if (queue->count < queue->capacity) { | |
int oldCapacity = queue->capacity; | |
queue->capacity = SHRINK_CAPACITY(oldCapacity); | |
queue->dq = SHRINK_ARRAY(vm, queue->dq, Value, oldCapacity, queue->capacity); | |
} | |
return newResultSuccess(vm, data); | |
return data; |
We should definitely think about sizing down queue sizes if it meets a certain threshold, but we wouldn't want it to happen each call to pop()
(as count is always going to be less than capacity in this case)
Something to think about with lists too actually, I don't think they size down
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.
Curious your thoughts on this. I changed the shrink operation to only shrink the underlying array if the count is less than half the capacity but greater than the default size.
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 like it yep!
Signed-off-by: Brian Downs <brian.downs@gmail.com>
Signed-off-by: Brian Downs <brian.downs@gmail.com>
Signed-off-by: Brian Downs <brian.downs@gmail.com>
Signed-off-by: Brian Downs <brian.downs@gmail.com>
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.
Sorry last round of comments !
Signed-off-by: Brian Downs <brian.downs@gmail.com>
More HTTP failures. I'd restart but I don't have that option to do so in the interface. |
Signed-off-by: Brian Downs <brian.downs@gmail.com>
Thanks very much for this! |
Well detailed description of the change :
Added a module providing a queue.
Resolves: #
Type of change:
Bug fix
New feature
Breaking change (fix or feature that would cause existing functionality to not work as expected)
Housekeeping
Tests have been updated to reflect the changes done within this PR (if applicable).
Documentation has been updated to reflect the changes done within this PR (if applicable).
Preview (Screenshots) :