You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to use lane to store a variable list of things where the oldest items are only the ones being removed and the newest go in front. Naturally, a queue from this package would work great, but when printing the contents of the queue, you have to destroy it by popping everything off. This makes my brain hurt when trying to figure out whether I can safely print the contents this way while another thread may be writing to the queue, as the locks are per operation (pop), and there's no way to lock the list for the duration of the copy process.
I would like to propose one of two things:
A copy method that would generate a new dequeue, stack, etc struct that is completely independent from the source object - this would allow me to store things in my dequeue and copy it before using dequeue repeatedly to print out the contents
A contents (or something) method that would return something like an array of the items in the list. This way I could extract the contents of my dequeue to display without modifying the dequeue.
What do you think?
The text was updated successfully, but these errors were encountered:
stephen304
changed the title
Copy/Contents Queue Feature
Copy/Contents of Methods
Mar 19, 2015
First of all, sorry for the looooooonnng reply delay :-)
That's an interesting point!
I really like the idea of a Copy method. That would bring a touch of immutability and indeed allow you keep track of what your doing easily. The only concern I would have in this case is how would that work out with the locks?
I'm not very fond of the idea to expose the items of the list as a method. The main reason is that I created this library to provide a higher level implementation compared to the standard library. Probably a bit more opinionated too :-) I think you should consider the standard library heap interface if you absolutely need to have control on the container.
Talking about this, I realize it might be a good idea to add a Lock and Unlock methods to the data structures. That would probably ease the interactions with the structs in concurrent algorithm context!
I'd like to use lane to store a variable list of things where the oldest items are only the ones being removed and the newest go in front. Naturally, a queue from this package would work great, but when printing the contents of the queue, you have to destroy it by popping everything off. This makes my brain hurt when trying to figure out whether I can safely print the contents this way while another thread may be writing to the queue, as the locks are per operation (pop), and there's no way to lock the list for the duration of the copy process.
I would like to propose one of two things:
What do you think?
The text was updated successfully, but these errors were encountered: