As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [queue]

A queue is an ordered, first-in-first-out (FIFO) data structure. Typical implementations of queues support pushing elements to the back and popping them off the front position.

Filter by
Sorted by
Tagged with
3 votes
1 answer
881 views

Rust Task Queue

The purpose of this program is to have one thread (main thread) working on I/O reading lines from a file and feeding it to a pool of worker threads whose job is to perform some processing on each line ...
the_endian's user avatar
  • 1,333
5 votes
4 answers
139 views

A queue implemented using an array

We've just finished learning about queues in my data structures class; I want to make sure I really understand it. I'm still feeling a bit lost on how to optimize the data use of a queue. I've ...
TheMachoMuchacho's user avatar
6 votes
1 answer
974 views

Single producer single consumer wait-free object container

I have a fast producer thread and a slow consumer thread. The consumer processes as many objects as it can and simply ignores the rest in order to not slow down the producer. Therefore, I used a one-...
purefanatic's user avatar
5 votes
1 answer
389 views

Implementing a queue using a linked-list

In my intro CS class we're reviewing data structures. I'm currently working on implementing a queue using a linked list (FIFO) in C. I'd appreciate a review of the implementation as well as of my ...
Ivan Stimac's user avatar
0 votes
1 answer
75 views

C++ container to manage waiting/sent messages

In my project I send messages, so there are items that should be sent and that were already sent. I want to have container to manage these two entities. The container I wrote seems to work ok. It ...
Yura's user avatar
  • 203
1 vote
1 answer
180 views

DynamicList/LinkedList Queue Implementation

here is my LinkedList Queue Implementation , seems like its almost like the linkedlist implementation with little differences mainly in the poll() method, i think that the offer() method is same like ...
E.Etem's user avatar
  • 31
3 votes
1 answer
2k views

Non-recursive BFS Maze Solving with Python

I wrote this program to help me understand how BFS and Queues work. (Also DFS if I replace the queue with a stack). It works, but I'm curious how well I implemented the algorithm. Are there any ...
Robin Andrews's user avatar
3 votes
0 answers
189 views

Templatized GLib asynchronous queue

I'm working on a legacy C++ project, which is using GLib for its Main Event Loop. This has caused a lot of ugliness because it mixes C++ and C paradigms (no C++ wrapper for GLib had been used). ...
Wizard79's user avatar
  • 141
2 votes
1 answer
63 views

A queue, used to print four strings

I made a queue that prints out strings a, b, c, and d. It works, but I want to make sure I don't have any unnecessary code. I realized that my main method prints the strings without the queue. Is ...
user179855's user avatar
1 vote
1 answer
3k views

Queue implementation using unique_ptr

I am trying out different data structures to learn more about smart pointers. I have created a queue implementation which has push, ...
skr's user avatar
  • 539
-1 votes
1 answer
811 views

Thread-safe queue mechanism

Is it my queue mechanism thread safe? I just wonder if I need concurrent collections. Need I lock Enqueue method? Console displays queue count in incorrect order, Does it affect on maxQueueCount at ...
dMilan's user avatar
  • 155
3 votes
2 answers
364 views

C++ workqueue class

This is a nice workqueue class template to keep the gui fluid, while data is being written into a database or into some file/network... ...
user1095108's user avatar
  • 1,404
9 votes
1 answer
3k views

A thread-safe priority queue keeping its elements unique

This class is intended to be used in situations where queue.Queue does not suffice, because the following two properties are needed. Every item in the queue can ...
Tobias Hermann's user avatar
12 votes
1 answer
488 views

Using decorated methods in a subclass of deque to dump its state to a JSON file

I am sub-classing an object in python and I need to overload a bunch of the methods with very similar logic, essentially a call to super() and then some additional operations. I want to avoid ...
Alex's user avatar
  • 223
4 votes
1 answer
845 views

A thread safe task queue implementation using my own lock_guard in C++

As an exercise in multithreaded programming, I am trying to implement a basic FIFO task queue. For this, I also implement simplified version of my lock_guard, from ...
meguli's user avatar
  • 215
4 votes
1 answer
1k views

Packet process time simulation using queue

Here is my code for the below packet time simulation problem using queue. My code works correctly but it's slow, please help with suggestions to improve run time and other suggestions for performance ...
mghah's user avatar
  • 113
6 votes
1 answer
124 views

Response dispatcher for HTTP server

I’m writing a small HTTP server (just for fun and education). One important part is the response dispatcher. Responses for each socket should be sent in the order the requests were received. The idea ...
Yura's user avatar
  • 203
5 votes
2 answers
1k views

Implementation of deque

What can be simplified, altered, or implemented differently? I would like to know if there's a way to further improve this code. ...
Sunny Stealth's user avatar
6 votes
2 answers
4k views

Async Queue implementation without locking

I wrote a quick implementation of an async queue that utilizes a backing ConcurrentQueue. It was pretty much based on an implementation given in this Stack Overflow ...
9ee1's user avatar
  • 163
1 vote
1 answer
2k views

Deque implementation with array in Java

I'm trying to implement a deque data structure with an iterator in Java using array. Please help to review and point out things that I can improve on. ...
CaRtY5532's user avatar
5 votes
2 answers
903 views

A simple lock-free queue for work stealing

I am currently reading the book C++ Concurrency in Action by Anthony Williams. In chapter 9, he implemented a lock-based work stealing queue and mentioned it is possible to implement a lock-free queue ...
Elaine's user avatar
  • 51
3 votes
3 answers
21k views

implementing a queue using std::vector

I tried implementing a queue using std::vector, using some properties of vector class. Is there scope for further improvement in my code, to make it more efficient? ...
vibhanshu kumar's user avatar
1 vote
2 answers
1k views

Generic Queue data structure in C++

I am a mathematician attempting to become proficient with C++. At the moment I am learning about data structures. I am now writing a queue data structure using linked list from scratch. I have tested ...
Snorrlaxxx's user avatar
6 votes
2 answers
261 views

Dynamically sized queue

This is my first deep dive into C, and I want to make sure that I'm not doing anything stupid. The code below creates an "Array List" of sorts, which automatically resizes itself. This code is meant ...
t3ddftw's user avatar
  • 163
0 votes
1 answer
280 views

Queue manager. Multithreading management implementation

I want to write small server that has one thread that pushes some jobs into queue and several threads that pull the jobs and process it somehow. I wrote (of course no, I found an example) of blocking ...
Yura's user avatar
  • 203
0 votes
1 answer
230 views

Array-based Queue

Description: An array-based Queue class. Since this class is designed using an array the size of the Queue is limited to whatever the program gives you. MAX_SIZE ...
Hamidur Rahman's user avatar
1 vote
1 answer
2k views

Thread Safe Evicting Queue in Java

Just wrote an Evicting Queue implementation, as an ordinary Linked List working under the hood, in Java; which, I hope, I've made thread safe, could you review? Code: ...
Robert Hanigan's user avatar
9 votes
4 answers
1k views

Implementation of a queue

It's been nearly a year I've been using C++, and I have just implemented this queue. I've tested it in many different scenarios, and it seems to work completely fine. Would you mind telling me what ...
maufcost's user avatar
  • 379
4 votes
1 answer
185 views

Lock-free Immutable ConcurrentQueue

Similar to the code review I posted last week for an agent-based immutable replacement for ConcurrentDictionary, I have also created an agent-based immutable ...
Aaron M. Eshbach's user avatar
-1 votes
2 answers
113 views

List operation while implementing stack

This is a very basic problem of implementing a queue operation using two stacks. Until now there are no issues with the logic but the testing tool report it takes more time than usual. Test case ...
nirmalyad's user avatar
2 votes
0 answers
256 views

Throttle submissions to ExecutorService

To prevent an XY problem, I'll first explain the problem I am trying to solve: Problem I am trying to solve I want to send the contents of a MongoDB collection with a size of around 3 million ...
Stefan van den Akker's user avatar
5 votes
1 answer
502 views

Optimizing priority queue streaming algorithm in C++

This is a sorting algorithm that I wrote for finding the maximum \$n\$ elements at any time in a stream of IDs and integers with unknown length. I primarily do my coding in Python, so I'm not too ...
Xian's user avatar
  • 151
8 votes
2 answers
2k views

Sequential execution

I made a class that I think satisfies the conditions: Actions can be added to the queue at any time by any number of clients. ...
Ted's user avatar
  • 83
3 votes
3 answers
215 views

Singly-linked list queue

I recently learned the core .NET Queue type uses arrays internally, and that this is actually much more efficient. I've had a go at writing a singly-linked list ...
Lee's user avatar
  • 183
5 votes
2 answers
210 views

Queue Implementation in C++ [closed]

When reviewing my code, please consider these questions too: Any way to avoid using new/delete? Or are data structures like that normally and can't really use smart pointers? I was thinking of using ...
SRG's user avatar
  • 405
5 votes
1 answer
2k views

A Thread-Safe FIFO in C99

I started a little weekend project to try and learn how to multithread with pure C99 and POSIX threads. The project is composed of three threads, input, processing, and output, which communicate with ...
Bernardo Meurer's user avatar
3 votes
0 answers
569 views

Blocking Promise-driven queues with ECMAScript's async/await and generators

I implemented an AsyncQueue, whose dequeue() operation returns a Promise. The ...
ComFreek's user avatar
  • 751
1 vote
1 answer
111 views

ResizableArray based queue implementation

I am implementing basic data structures in Java. I have written this simple resizing array queue implementation and looking for ways to simplify the implementation as it looks like I am using too many ...
Anurag Arora's user avatar
3 votes
2 answers
12k views

Circular Queue Implementation Using Array in java

Here is my code of Array Implementation of Queue in java. ...
Sagar Devkota's user avatar
3 votes
2 answers
1k views

Python stack and queue classes, implemented using lists

I have made a stack and queue implementation with OOP in Python (sorry for variable names) . It is made from scratch. I just watched a video how these two things work. I am still trying to improve in ...
P. Bolfa's user avatar
  • 261
5 votes
2 answers
2k views

Queue With Variable Size Buffer

I'm working on creating a queue to hold variable sized data buffers up to 256 bytes in length, however most often the buffers will be much smaller (typically around 10-15 bytes). To avoid the wasted ...
Otus's user avatar
  • 53
2 votes
0 answers
565 views

Producer Consumer Using TPL Dataflow

I have written the following class which is supposed to act as a consumer of messages that are passed in from producers and forward them onto amazon SQS, I have made a compromise by starting the ...
xerxes's user avatar
  • 349
1 vote
3 answers
3k views

Deque implemented using a circular array

I found a tutorial on implementing a deque using a circular array. I changed the implementation but I am not sure if it is correct or not. So I have one question: I wrote code that uses an ...
beehuang's user avatar
  • 111
1 vote
1 answer
770 views

Implement a queue class in Python

Problem:Implement a queue class in Python: It should support 3 APIs: queue.top(): prints current element at front of queue queue.pop(): takes out an element from front of queue queue....
Latika Agarwal's user avatar
1 vote
0 answers
124 views

Immutable Queue with Bulk-Enqueue

I recently needed a data structure with FIFO queue semantics that supported efficient bulk-insertion (often need to enqueue thousands of messages at once). I took a look at Purely Functional Data ...
Aaron M. Eshbach's user avatar
1 vote
0 answers
121 views

thread safe queue with watermarks

A thread-safe queue suspending/resuming the producer when respectively upper/lower watermark has been crossed. Intended usage - interchange between a non-blocking IO loop thread and a consumer running ...
bobah's user avatar
  • 361
1 vote
0 answers
692 views

Continuous queue with delay support

I'm new to programming in Python, and I have a task to try and create continuous queue but with delay support. I need to use this for a messaging queue and simulate network latency at different rates ...
Bryan Davis's user avatar
4 votes
1 answer
3k views

A "zero copy" concurrent queue in C++ that supports exactly two threads; one for pushing and one for popping

One thread is limited to one action (i.e. there is a push-thread and a pop-thread and the push-thread can't pop and vice versa). By "zero copy" I mean no copying of data (mostly C++ structures) will ...
Chani's user avatar
  • 273
10 votes
3 answers
1k views

A concurrent queue that supports exactly two threads and not more. One thread is allowed to push, the other to pop

My header file implementation: ...
Chani's user avatar
  • 273
4 votes
1 answer
3k views

Running a collection of BackgroundWorkers one after the other

In my project, I had three BackgroundWorkers that can be run independently, but I also wanted to allow the user to "Run All" of them, but not at the same time. They ...
Drew Chapin's user avatar
  • 1,059

1 2
3
4 5
9