queue

How do I clear the std::queue efficiently?

I am using std::queue for implementing JobQueue class. ( Basically this class process each job in FIFO manner). In one scenario, I want to clear the queue in one shot( delete all jobs from the queue). I don't see any clear method available in std::queue class. How do I efficiently implement the clear method for JobQueue class ? I have ...

enqueue() method adds one element to the queue: how to implement in C++?

I'm having a hard time trying to implement this method since array subscripts in C++ start with zero. The method add one element to the queue. You can use f (front) and r (rear) pointers and a sequential list of size n. If you find that additional variables are needed fell free. Thanks. Thats my try but I know its wrong: void QueueAr::...

Python: Queue.Queue vs. collections.deque

I need a queue which multiple threads can put stuff into, and multiple threads may read from. Python has at least two queue classes, Queue.Queue and collections.deque, with the former seemingly using the latter internally. Both claim to be thread-safe in the documentation. However, the Queue docs also state: collections.deque is an...

Please suggest .Net Job/Task Queue

I need to build a network of services that will process data. Each service needs its own task queue. Preliminary I will need operations like QueueTask, CancelTask, StopTask, GetTaskStatus and GetTaskProgress. I am looking for framework or fully built implementation of Task Queue. At this time I know some options: MSMQ - It OK for my n...

Why do priority queues mostly use 0 as the most important priority?

Why are most priority/heap queues implemented as 0 being the highest priority? I'm assuming I'm missing out some key mathematical principle. As I was implementing my own priority queue recently it seemed easier to write the insert function if priority went up with the integer value, but apparently people smarter than me think it should g...

Discrete Event Queuing Simulation

Hello, I'm stuck trying to implement a single server queue. I've adapted some pseudocode from Norm Matloff's Simpy tutorial to Python and the code is here. Now I am struggling to find some way to calculate the mean waiting time of a job/customer. At this point my brain has tied itself into a knot! Any pointers, ideas, tips or pseudoco...

A good method for conflating queue entries

I have a pool of threads which are fed tasks from a queue. Generally, a small number of threads are able to keep the queue empty. Occasionally, a particularly large burst of events will keep the queue size above zero for some time, but not for long. My concern is regarding events that are duplicates or carry data that obsoletes previous...

In-process ActiveMQ producer/consumer example?

I'm investigating using ActiveMQ as an embedded in-process message queue in my application, but I'm a bit stuck on how I go about starting such an application up. I envision it like so (pseudocode, of course): configureBroker () broker.start () createProducer (broker) producer.start () for each desired consumer createConsumer (br...

Loop through list in a thread continually as it receives new elements

I'm really not sure how to approach this, but I am subscribing to events fired within a custom class and ideally I wish to queue them and handle them first in first out as they come in. I am aware of Queue<T> and I think I should use this? but my question is in the event handler when my message is received, would I simply Enqueue() to t...

Java PriorityQueue removal of arbitrary elements performance

Say I have a java PriorityQueue (which java implements as a heap) that I iterate over to remove elements based on some criteria: PriorityQueue q = new PriorityQueue(); ... Iterator it = q.iterator(); while(it.hasNext()){ if( someCriterion(it.next()) ) it.remove(); } How long does each remove() operation take? I'm not sure ...

How to write to MQMessage: multiple Write calls, or StringBuilder?

I'm brand new to WebSphere MQ. I'm using IBM's .NET classes (IBM.WMQ) to put a request message and then get a response message. The MQMessage object has a number of Writexxx methods for various data types. I need to write a variety of different data elements to the request message. My question is, should I call the appropriate Write meth...

Penalties of a script constantly looping in the background

I know this topic has been discussed in the past, but I am a tiny bit paranoid about resource usage. I am looking into writing a daemon for queing jobs to archive files into zip files for a web app i am working on. It would behave something like this: while True: while morejobs(): zipfile() sleep(15seconds) What sort ...

Time restricted service

Hi, i'm developing an app that make requests to the Musicbrainz webservice. I read in the musicbrainz manual to not make more than one request per second to the webservice or the client IP will be blocked. What architecture do you suggest in order to make this restriction transparent to the service client. I would like to call a me...

Raw Socket Receive Buffer

Hi All, We are currently testing a Telecom application over IP. We open a Raw Socket and receives messages from the remote side (msgrate@750+msgs/second approx size of 180 bytes excluding IP). On top of the Raw socket sits a layer called SCTP (just like TCP) which is indicating every now and then that it is missing some packets. Now, w...

Spring Integration: Hooking web services to a FIFO queue

I'm still struggling with Spring Integration- here's my scenario: A web service gets a request from client A web service puts the request onto a queue A queue consumer processes the messages FIFO and sends a response that gets routed back to the web service Web services sends response back to client A There will be multiple web servi...

How should I handle Multi-threading in Java?

I am working on a practical scenario related with Java;a socket program. The existing system and the expected system are as follows. Existing System - The system checks that a certain condition is satisfied. If so It will create some message to be sent and put it into a queue. The queue processor is a separate thread. It periodically ...

Thread queues for dummies...

I have what I assume is a pretty common threading scenario: I have 100 identical jobs to complete All jobs are independent of each other I want to process a maximum of 15 jobs at a time As each job completes, a new job will be started until all jobs have been completed If you assume that each job will fire an event when he completes ...

Different types of Queues and what open source tools available to test them

What are the different types of Queues (like MSMQ, JMS ques) and what open source tools are available to test them? Also, could you please tell which open source tool is best suited for testing what type of Queues? ...

Building a high performance and automatically backupped queue

Please give me some hints on my issue. I'm building a queue data structure that: has a backup on hard disk at realtime and can restore the backup Can respond to massive enqueue/dequeue request Thank you! ...

Queue implementation

What is the best way to implement fast queue where multiple users try to access to about 100 000 records. Only one user can get one unique row. Now im using sql database (firebird) but there is a lot of problems deadlocks / high database load. ...