A queue is an ordered, first-in-first-out data structure. Typical implementations of queues support pushing elements to the back and popping them off the front position.
8
votes
1answer
97 views
Thread-safe concurrent FIFO queue in C++
Is this the correct way to implement a thread-safe concurrent FIFO queue in C++? It requires passing unsigned char* arrays of binary data.
Thread Safe Concurrent Queue
#include <queue>
...
5
votes
1answer
88 views
Optimization for add function in queue
I would prefer if more experienced users could give pointers on how I can optimize and think better when writing code.
Using Homework Questions as reference, as this is a homework related question. ...
3
votes
0answers
97 views
Continuously receive messages async from Azure Service Bus Queues
I'd like to get input on my approach of continuously receiving messages from an Azure Service Bus queue using the async part of the library.
My main concern being whether its "safe" to use ...
9
votes
2answers
106 views
First-come first-serve job scheduling algorithm
I tried to make the code for implementation of first-come first-serve job scheduling algorithm as used by operating systems.
How can I make it better?
I am using turbo C++ compiler
...
7
votes
2answers
158 views
Multi producer/consumer queue (without Boost) in C++11
Not lock-free, but still only C++11 and no Boost. It also supports timeouts.
Edit: Here is an updated version after the reviews (use wait_until() with a predicate lambda, and calling notify_one() ...
2
votes
3answers
123 views
Priority Queue in C#
I develop a small game using C# and need A* in it. For that, I need a PriorityQueue, which .NET does not have. I wanted to make my own one for practice. Here is it, please comment on performance and ...
5
votes
1answer
74 views
Very simple priority queue
I wrote this code to handle a fixed number of priority levels. I believe performance will depend on the number of priority levels.
Considering only a few levels (3 to 5), is there a more efficient ...
5
votes
2answers
87 views
Queue implementation in C
I was reading about opaque pointers and decided to try it with queues. Please review my code and let me know if there are any errors and how to improve code quality and performance.
It uses lines to ...
2
votes
4answers
168 views
A more efficient enqueue algorithm in Java
So I have this simple code in Java. It enqueue (adds) and element to the end of the queue (implemented by an ArrayList) without changing the original queue.
public class MyQueue<T>{
private ...
1
vote
1answer
36 views
FixedSizePriorityQueue - Review Request
I implemented the FixedSizePriorityQueue class. The intended purpose is that, you can add as many elements as you want, but it will store only the greatest maxSize elements.
I would like any ...
1
vote
1answer
77 views
Can someone review my implementation of a Queue?
So here is my Queue interface:
public interface Queue<E> {
/**
* Add an item to the rear of the queue.
*
* @param item
* Item to be added.
*/
public ...
2
votes
2answers
185 views
Implement data structure overflow queue
Implement data structure overflow queue. Overflow queue is a normal queue with one extra property. It never throw Stack overflow exception. So whenever queue becomes full, it replaces the oldest ...
1
vote
1answer
121 views
Removing nodes from queue
I had an exercise to create two methods for simple queue class, first to delete last element and second to delete element at k position. Particularly I'm not asking for better implementation. Is it ...
2
votes
2answers
255 views
Fixed size priority queue
I've tried implementing priority queue with fixed size in Java using TreeSet and overriding add() method:
public class FixedSizePriorityQueue<E> extends TreeSet<E> {
private final int ...
1
vote
0answers
380 views
Javascript Queue for async functions
Based on the answer to my previous question on Stack Overflow, I put together the following Queue class. I realize there are already libraries out there to do this. However, I wanted to actually ...
2
votes
2answers
676 views
Thread safe message queue without mutex in C
I'm trying to write a message queue implementation
so my threads can exchange data.
To keep things simple, the queue is only responsible for
sending pointers to memory. Only one thread may send ...
4
votes
1answer
267 views
Javascript Queue Object
I created a Queue object when answering this question and I was wondering if it could do with some improvement.
Here is the current code:
var Queue = (function () {
Queue.prototype.autorun = ...
1
vote
0answers
129 views
Reducing memory footprint with queue of classes
I hope I've asked this in the right area. I'm writing a program that deals with enqueueing a class on STL queue in C++. Initially it queues initializations of the class. Then while the queue is not ...
0
votes
0answers
33 views
Extract equally from X queues to one queue with Y elements
I need to implement a system of queueing that extracts elements equally from x queues to one single queue with y positions.
Let's say I have 5 queues, each with a number of elements and I need to ...
2
votes
2answers
288 views
Optimize BFS weighted search in python
I have a weighted BFS search in python for networkx that I want to optimize:
def bfs(graph, node, attribute, max = 10000):
# cProfile shows this taking up the most time. Maybe I could use heapq ...
1
vote
1answer
745 views
Queue implementation Doubly Linked List [closed]
Here is my implementation for a queue using doubly linked list:
QUEUE-EMPTY
if L.head == NIL
return True
else return False
QUEUE(x):
if L.head == NIL:
x.prev = NIL
L.head = x
else
...
6
votes
1answer
176 views
BFS for creating a queue without repetitions and with loops in the graph
I have a pipeline with loops of filters and one input filter. The rest are splitters, transform and output.
I would like my code to go over the filters and push them into a queue (order is ...
5
votes
4answers
2k views
Optimizing a thread safe Java NIO / Serialization / FIFO Queue
I've written a thread safe, persistent FIFO for Serializable items. The reason for reinventing the wheel is that we simply can't afford any third party dependencies in this project and want to keep ...
6
votes
1answer
294 views
A queue that switches from FIFO mode to priority mode
I implemented a queue capable of operating both in the FIFO mode and in the priority mode: when the priority mode is enabled, the elements are taken in order of decreasing priority; when the priority ...
4
votes
2answers
386 views
Binary tree max sum level - better design?
I have written some code for finding a level in a binary tree, having a maximum number of elements. I have a few questions:
Is it a good design? I have used 2 queues but the total sum of elements ...
2
votes
1answer
146 views
Message queues in Common Lisp
General advice for a change. This is an implementation of message queues that I'm going to use for some work on an actors model library.
(defclass message-queue ()
((messages :accessor messages ...
2
votes
2answers
887 views
Robust logging solution to file on disk from multiple threads on serverside code
I have implemented a socket listener that runs on my Linux Ubuntu server accepting connections and then starting up a new thread to listen on those connections (classic socket listener approach). ...
1
vote
1answer
3k views
Simple generic multithreaded queue
This is a simple thread safe queue that is used in a producer-consumer model.
public class ThreadedQueue<TType>
{
private Queue<TType> _queue;
private object _queueLock;
...
4
votes
2answers
2k views
Did I need to use lock to ensure that Queue.Dequeue is Thread Safe in this case on .NET 2.0?
Is this ok? I am using C# and .NET 2.0
I have this Queue declared in my class :
static private Queue<SignerDocument> QUEUE = new Queue<SignerDocument>();
I fill this Queue with some ...
6
votes
2answers
681 views
Custom JavaScript function queue
For fun, I made a function queue in JavaScript. I named it tinyq. You can add functions to it, and each function is passed the next function in the queue. You can also pass parameters to the ...
3
votes
2answers
3k views
Queue Implementation
First time I'm using stackexchange. I'm in 8th standard. I tried to implement Queue in Java. I wrote something like this> Right now I'm not able to test it because I don't have JVM in my machine. So I ...
5
votes
3answers
3k views
Java blocking queue
public class BQueue<T> {
private Queue<T> q = new LinkedList<T>();
private int limit;
public BQueue(int limit) {
this.limit = limit;
}
public ...
2
votes
1answer
211 views
Trying to improve my jQuery animation queue
So I built a little baseball "scouting report" graphic that shows stats for players. As you page through the players, their images slide in and out of the graphic. I worked out a way to do this using ...
7
votes
1answer
495 views
Double-Ended Queue - Have I over-engineered it again?
I'm working on an implementation of the Double-Ended Queue as a Doubly-Linked List (for personal enrichment), and I was wondering if anyone minded taking a look at my Constructor/Destructor and Empty ...
3
votes
1answer
3k views
A simple thread-safe queue in python
I'm trying to implement a kind of message queue. Tasks will come in at unknown random times, and must be executed FIFO. I can do multiple tasks in one hit, but the setup and tear down unavoidably ...
2
votes
2answers
492 views
FIFO queue for audio data
I have created a data structure to handle some audio data I am generating (simple sine wave right now). It had some errors in it due to some misunderstanding of my ancient C knowledge that has been ...
-1
votes
1answer
299 views
Queue Dequeue/TryeDequeue PulseAll does not occur, [closed]
This is the very first message on CodeReview. To simplify my own process to get helped, i was sum all of my problem onto this GIST; https://gist.github.com/1057263
I hope this is ok. If anyone wants ...
2
votes
5answers
941 views
Bounded blocking queue
Can someone please review this code for me. I have not implemented all the methods for simplicity.
Original code:
/**
* Implements a blocking bounded queue from a given non-blocking unbounded queue ...
1
vote
1answer
1k views
What value the rear and front counter of an Array implementation of Queue start with? -1 or 0 or 1?
Is there anything wrong with this implementation of Queue with array?
I have started front = rear = -1.
Some references tend to start front = 0 like this:enter link description here
I think if ...
5
votes
3answers
1k views
fix ugly initialisation in while loop over queue
I have a loop structure, that I really don't like. It's the initialisation I find appalingly ugly. Is there a nicer way to do the following?
Queue<Integer> queue = getMyQueue();
Integer element ...
8
votes
4answers
2k views
Circular Bounded Que using C#
I have implemented a circular bounded que using arrays as the base data structure. I'd appreciate if someone can review it for me.
class BoundedQueue<T> {
T[] que;
int head; ...
10
votes
6answers
10k views
A custom thread-pool/queue class.
I wanted a class which executes any number of tasks but only a certain amount at the same time (e.g. to download various internet content and keep the overall download speed at a good level). The ...
4
votes
1answer
1k views
Refactoring a multi-threaded producer-consumer model [closed]
This is an architecture question for a multi-threaded program which is going to be moved from C# .NET 2 to .NET 4. The program currently has multiple processing threads, and one database I/O thread. ...