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

Add timeout argument to python's Queue.join()

I want to be able to join() the Queue class but timeouting after some time if the call hasn't returned yet. What is the best way to do it? Is it possible to do it by subclassing queue\using metaclass?
olamundo
  • 23,991
  • 34
  • 108
  • 149
19
votes
6 answers

Get all items from thread Queue

I have one thread that writes results into a Queue. In another thread (GUI), I periodically (in the IDLE event) check if there are results in the queue, like this: def queue_get_all(q): items = [] while 1: try: …
Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412
18
votes
1 answer

Is there any way to list queues in a rabbitmq via pika?

I know that we can do this to list queue in a rabbitmq. rabbitmqctl list_queues but how can I do this via pika?
kerwin
  • 941
  • 2
  • 12
  • 22
18
votes
2 answers

What are the advantages of Blocking Queue in Java?

I am working on a project that uses a queue that keeps information about the messages that need to be sent to remote hosts. In that case one thread is responsible for putting information into the queue and another thread is responsible for getting…
Chathuranga Chandrasekara
  • 20,548
  • 30
  • 97
  • 138
18
votes
2 answers

Create Hash Value on a List?

I have a List with 50 instances in it. Each of the instances has 1 or 2 unique properties, but in a way they are all unique because there is only one at position in the list, etc. I would like to come up with a unique way to "hash"…
Snowy
  • 5,942
  • 19
  • 65
  • 119
18
votes
3 answers

Multithreaded .NET queue problems

I'm have a wierd error in my code. It's extremely rare (happens once every few weeks maybe), but it's there and I'm not sure why. We have 2 threads running, 1 thread gets networked messages and adds them to a Queue like…
Hannesh
  • 7,256
  • 7
  • 46
  • 80
18
votes
4 answers

Tensorflow Queues - Switching between train and validation data

I am trying to make use of queues for loading data from files in Tensorflow. I would like to to run the graph with validation data at the end of each epoch to get a better feel for how the training is going. That is where i am running into problems.…
ronrest
  • 1,192
  • 10
  • 17
18
votes
4 answers

target parameter in DispatchQueue

In Swift 3, the creation of a DispatchQueue instance: DispatchQueue(label: String, qos: DispatchQoS, attributes: DispatchQueue.Attributes, autoreleaseFrequency: DispatchQueue.AutoreleaseFrequency, …
pzs7602
  • 1,233
  • 1
  • 10
  • 9
18
votes
6 answers

Implementing a simple queue with PHP and MySQL?

I have a PHP script that retrieves rows from a database and then performs work based on the contents. The work can be time consuming (but not necessarily computationally expensive) and so I need to allow multiple scripts to run in parallel. The rows…
Nate
  • 26,164
  • 34
  • 130
  • 214
18
votes
4 answers

Lock Free Queue -- Single Producer, Multiple Consumers

I am looking for a method to implement lock-free queue data structure that supports single producer, and multiple consumers. I have looked at the classic method by Maged Michael and Michael Scott (1996) but their version uses linked lists. I would…
Shirish
  • 181
  • 1
  • 1
  • 4
18
votes
4 answers

Is RabbitMQ capable of "pushing" messages from a queue to a consumer?

With RabbitMQ, is there a way to "push" messages from a queue TO a consumer as opposed to having a consumer "poll and pull" messages FROM a queue? This has been the cause of some debate on a current project i'm on. The argument from one side is that…
user1431072
  • 1,272
  • 2
  • 13
  • 32
18
votes
5 answers

Queues against Tables in messaging systems

I've been experiencing the good and the bad sides of messaging systems in real production environments, and I must admit that a well organized table or schema of tables simply beats every time any other form of messaging queue, because: Data are…
friol
  • 6,996
  • 4
  • 44
  • 81
18
votes
3 answers

Can I somehow share an asynchronous queue with a subprocess?

I would like to use a queue for passing data from a parent to a child process which is launched via multiprocessing.Process. However, since the parent process uses Python's new asyncio library, the queue methods need to be non-blocking. As far as I…
balu
  • 3,500
  • 4
  • 34
  • 35
18
votes
4 answers

Node.js/Express and parallel queues

We are building an infrastructure which features a Node.js server and Express. In the server, what is happening is as follow: The server accepts an incoming HTTP request from client. Server generates two files (this operation can be "relatively…
ItalyPaleAle
  • 7,185
  • 6
  • 42
  • 69
18
votes
5 answers

How do I build a lockless queue?

I've spent today looking into lockless queues. I have a multiple producer, multiple consumer situation. I implemented, for testing, a system using the Interlocked SList thing under Win32 and it doubled the performance of my heavily threaded task…
Goz
  • 61,365
  • 24
  • 124
  • 204