Questions tagged [queue]

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.

  • A queue is not limited to a fixed capacity
    • A bounded queue is a queue limited to a fixed number of items
  • A doubly linked list is a good implementation choice

Operations

  • enqueue - pushes an element to the end of the queue
  • dequeue - pops an element from the front of the queue

See Also

Resources

Queue Wikipedia Article

11098 questions
18
votes
2 answers

Java: ArrayBlockingQueue vs. LinkedBlockingQueue

I think that, in most cases, the ArrayBlockingQueue will perform better than the LinkedBlockingQueue. However, that is the case when there is always enough room in the array... If it gets full, it's not very predictable whether it will perform so…
Eduardo Bezerra
  • 1,923
  • 1
  • 17
  • 32
18
votes
5 answers

RabbitMQ wait for multiple queues to finish

Ok here is an overview of what's going on: M <-- Message with unique id of 1234 | +-Start Queue | | | <-- Exchange /|\ / | \ / | \ <-- bind to multiple queues Q1 Q2 Q3 \ | / <-- start of the problem is here \ …
Phill Pafford
  • 83,471
  • 91
  • 263
  • 383
18
votes
3 answers

Can python threads access variables in the namespace?

I have a script that creates a bunch of threads, runs a program to use the threads to run tasks from a queue, and returns something from each thread. I want to count how many of these returned successfully, so I set a variable "successful=0" and…
Oliver
  • 2,182
  • 5
  • 24
  • 31
17
votes
7 answers

Thread-safe blocking queue implementation on .NET

I'm looking for an implementation of thread-safe blocking queue for .NET. By "thread-safe blocking queue" I mean: - thread-safe access to a queue where Dequeue method call blocks a thread untill other thread puts (Enqueue) some value. By the moment…
Shrike
  • 9,218
  • 7
  • 68
  • 105
17
votes
1 answer

AWS SQS FIFO Queue: The queue should either have ContentBasedDeduplication enabled or MessageDeduplicationId provided explicitly?

When I try to add a message to my FIFO SQS using AWS CLI I get: An error occurred (InvalidParameterValue) when calling the SendMessage operation: The queue should either have ContentBasedDeduplication enabled or MessageDeduplicationId provided…
java12399900
  • 1,485
  • 7
  • 26
  • 56
17
votes
6 answers

Queue ForEach loop throwing InvalidOperationException

I haven't used Queues to any real degree before, so I might be missing something obvious. I'm trying to iterate through a Queue like this (every frame): foreach (var e in qEnemy) { //enemy AI code } When an enemy dies, the…
keyboardP
  • 68,824
  • 13
  • 156
  • 205
17
votes
7 answers

Fast way to remove a few items from a list/queue

This is a follow up to a similar question which asked the best way to write for item in somelist: if determine(item): code_to_remove_item and it seems the consensus was on something like somelist[:] = [x for x in somelist if not…
highBandWidth
  • 16,751
  • 20
  • 84
  • 131
17
votes
3 answers

d3.js v5 - Promise.all replaced d3.queue

I've been using d3.js v4 for sometime now and I've learned that Mike Bostock has replaced the d3.queue in the v5 release with the Promise native JavaScript object. I would like to check with you if this code that I have written is properly queuing…
Marco A. Ferra
  • 193
  • 1
  • 1
  • 7
17
votes
8 answers

Implementing an efficient queue in Python

I have been trying to implement a queue in Python, and I've been running into a problem. I am attempting to use lists to implement the Queue data structure, however I can't quite figure out how to make enqueue and dequeue O(1) operations. Every…
random_coder_101
  • 1,782
  • 3
  • 24
  • 50
17
votes
5 answers

How to send message headers (properties) for a message in active mq web console localhost:8161?

I searched a lot in web, couldn't find any answers.
Raghunandan J
  • 584
  • 1
  • 6
  • 22
17
votes
4 answers

java.util.ConcurrentLinkedQueue

I want to use java.util.ConcurrentLinkedQueue as a non-durable queue for a Servlet. Here's the blurb from the javadoc for the class. An unbounded thread-safe queue based on linked nodes. A ConcurrentLinkedQueue is an appropriate choice when many…
ashitaka
  • 3,928
  • 7
  • 38
  • 43
17
votes
4 answers

why is concurrent_queue non-blocking?

In the concurrency runtime introduced in VS2010, there is a concurrent_queue class. It has a non blocking try_pop() function. Similar in Intel Thread Building Blocks (TBB), the blocking pop() call was removed when going from version 2.1 to 2.2. I…
eli
  • 662
  • 8
  • 18
17
votes
5 answers

C++ - LNK2019 error unresolved external symbol [template class's constructor and destructor] referenced in function _main

[[UPDATE]] -> If I #include "Queue.cpp" in my program.cpp, it works just fine. This shouldn't be necessary, right? Hey all -- I'm using Visual Studio 2010 and having trouble linking a quick-and-dirty Queue implementation. I started with an empty…
Squirrelsama
  • 5,480
  • 4
  • 28
  • 38
17
votes
1 answer

Sharing many queues among processes in Python

I am aware of multiprocessing.Manager() and how it can be used to create shared objects, in particular queues which can be shared between workers. There is this question, this question, this question and even one of my own questions. However, I need…
Wapiti
  • 1,851
  • 2
  • 20
  • 40
17
votes
4 answers

Laravel Queue worker on Heroku

I'm running Laravel 5 on Heroku. I'm using the Laravel Queue for background tasks. What is/are the most reliable ways to listen to the queue and run it's jobs?
Till
  • 1,107
  • 12
  • 28