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.
10
votes
7answers
7k 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 ...
7
votes
4answers
1k 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; ...
6
votes
1answer
263 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 ...
5
votes
2answers
473 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 ...
5
votes
1answer
418 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 ...
5
votes
1answer
897 views
Refactoring a multi-threaded producer-consumer model
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. ...
4
votes
3answers
711 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 ...
4
votes
2answers
1k 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 ...
4
votes
3answers
1k 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 ...
4
votes
2answers
250 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 ...
3
votes
4answers
559 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 ...
3
votes
2answers
2k 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 ...
2
votes
5answers
709 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 ...
2
votes
2answers
91 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 ...
2
votes
2answers
460 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). ...