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
28
votes
4 answers

Clojure agents consuming from a queue

I'm trying to figure out the best way to use agents to consume items from a Message Queue (Amazon SQS). Right now I have a function (process-queue-item) that grabs an items from the queue, and processes it. I want to process these items…
erikcw
  • 10,787
  • 15
  • 58
  • 75
28
votes
2 answers

Python Exception in thread Thread-1 (most likely raised during interpreter shutdown)?

My friend and I have been working on a large project to learn and for fun in python and PyGame. Basically it is an AI simulation of a small village. we wanted a day/night cycle so I found a neat way to change the color of an entire surface using…
Nick Jarvis
  • 361
  • 1
  • 3
  • 9
28
votes
2 answers

Filling a queue and managing multiprocessing in python

I'm having this problem in python: I have a queue of URLs that I need to check from time to time if the queue is filled up, I need to process each item in the queue Each item in the queue must be processed by a single process (multiprocessing) So…
Tibo
  • 281
  • 1
  • 3
  • 3
28
votes
6 answers

Concurrent and Blocking Queue in Java

I have the classic problem of a thread pushing events to the incoming queue of a second thread. Only this time, I am very interested about performance. What I want to achieve is: I want concurrent access to the queue, the producer pushing, the…
Yiannis
  • 880
  • 1
  • 7
  • 14
26
votes
9 answers

Where is the Queue class in the Java Collections?

I only see a Queue interface, is there no Queue class in the Java Collections?
Sinister
26
votes
3 answers

Difference requiresMainQueueSetup and dispatch_get_main_queue?

I am trying to learn about creating react-native modules for iOS and there is one aspect that came up Official documentation on threading mentions this block of code alongside its variations - (dispatch_queue_t)methodQueue { return…
Ilja
  • 44,142
  • 92
  • 275
  • 498
26
votes
2 answers

How do Google App Engine Task Queues work?

I'm confused about Task execution using queues. I've read the documentation and I thought I understood bucket_size and rate, but when I send 20 Tasks to a queue set to 5/h, size 5, all 20 Tasks execute one after the other as quickly as possible,…
Will Curran
  • 6,959
  • 15
  • 59
  • 92
26
votes
3 answers

C++ queue - simple example

I can't find simple example how to use queues in C++ for pointers to some myclass objects. I have code like this: class myclass{ string s; }; myclass *p = new myclass(); my_queue.push(p); //something.... p =…
Ondra
  • 3,100
  • 5
  • 37
  • 44
26
votes
2 answers

How to clear a queue in Oracle AQ

I've been testing Oracle AQ for the first time. I have managed to create 2000 rows of test inserts into the queue I created. Now, I'd like to clear those out. As I was teaching myself, I set the expiry time to be a month. I can't wait that long. …
jeph perro
  • 6,242
  • 26
  • 90
  • 124
26
votes
5 answers

A fast queue in Java

I am looking for a fast queue implementation in Java. I see that LinkedList implements the Queue interface, but it will only be as fast as a LinkedList right? Is there a way to have a queue that will be faster especially for add (I only need poll,…
Eqbal
  • 4,722
  • 12
  • 38
  • 47
25
votes
6 answers

"Cannot instantiate the type..."

When I try to run this code: import java.io.*; import java.util.*; public class TwoColor { public static void main(String[] args) { Queue theQueue = new Queue(); } public class Edge { //u and v are…
StickFigs
  • 253
  • 1
  • 3
  • 4
25
votes
2 answers

laravel queues - how sync driver works? Does it executes in a separate process/thread or the main execution thread?

I am sending push notifications from my server and want it to simply be executed in a background process. I've read the Laravel docs and I know about database driver and some other options as well. I've got it working with database driver on my…
tmw
  • 1,424
  • 1
  • 15
  • 26
25
votes
1 answer

What is the best option for a (Python 3) task queue on Windows now that Celery 4 has dropped Windows support?

We run a Flask site under IIS on Windows, and for out-of-process tasks we use Celery. Celery has given us some problems under Windows, but for now we are satisfied running version 3.1.12, using RabbitMQ/AMQP as a back-end, which works under…
Erik Oosterwaal
  • 4,272
  • 3
  • 44
  • 64
25
votes
5 answers

c# stack queue combination

is there in C# some already defined generic container which can be used as Stack and as Queue at the same time? I just want to be able to append elements either to the end, or to the front of the queue thanks
Mat
  • 11,263
  • 10
  • 45
  • 48
25
votes
5 answers

Using Queue in python

I'm trying to run the following in Eclipse (using PyDev) and I keep getting error : q = queue.Queue(maxsize=0) NameError: global name 'queue' is not defined I've checked the documentations and appears that is how its supposed to be placed. Am I…
Bain
  • 834
  • 6
  • 11
  • 17