PriorityLinkedQueue ?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

PriorityLinkedQueue ?

Hanson Char
>This might be useful for creating work load with priority associated with it and submitting
> to the threadpool executor.

If you can determine the priority of each work item a priori, you can assign it an expired "delay" and place it on a j.u.c.DelayQueue.  The higher the prioirty, the further into the past a work item should be "expired".

The consumer(s) can then dequeue/process items with a priority according to their expiration.

However, if the prioirty of each work item needs to be changed after it has been placed on the queue, then this won't work as DelayQueue would ignore such changes.

It would be really nice if there is a "decrease Key" operation as Tim Peierls pointed out earlier under the email thread "
Changing delays in DelayQueue ?"

Hanson

On 9/11/06, Hanson Char <[hidden email]> wrote:
Is j.u.PriorityQueue what you are looking for ?

Hanson


On 9/11/06, rbalamohan <[hidden email]> wrote:
The results look really promising.

On a similar note, I was wondering why we don't have "PRIORITY BASED LINKED QUEUE"

This might be useful for creating work load with priority associated with it and submitting to the threadpool executor.

~Rajesh.B


_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
Reply | Threaded
Open this post in threaded view
|

Re: PriorityLinkedQueue ?

Hanson Char
Oops, forget about the "delay" priority.  Better to directly use j.u.c.PriorityBlockingQueue and implement Comparable for each q item.  There is still no "decrease Key" operation  in PriorityBlockingQueue though ...

H

On 9/11/06, Hanson Char <[hidden email]> wrote:
>This might be useful for creating work load with priority associated with it and submitting
> to the threadpool executor.

If you can determine the priority of each work item a priori, you can assign it an expired "delay" and place it on a j.u.c.DelayQueue.  The higher the prioirty, the further into the past a work item should be "expired".

The consumer(s) can then dequeue/process items with a priority according to their expiration.

However, if the prioirty of each work item needs to be changed after it has been placed on the queue, then this won't work as DelayQueue would ignore such changes.

It would be really nice if there is a "decrease Key" operation as Tim Peierls pointed out earlier under the email thread "
Changing delays in DelayQueue ?"

Hanson

On 9/11/06, Hanson Char <[hidden email]> wrote:
Is j.u.PriorityQueue what you are looking for ?

Hanson


On 9/11/06, rbalamohan <[hidden email]> wrote:
The results look really promising.

On a similar note, I was wondering why we don't have "PRIORITY BASED LINKED QUEUE"

This might be useful for creating work load with priority associated with it and submitting to the threadpool executor.

~Rajesh.B



_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
Reply | Threaded
Open this post in threaded view
|

Re: PriorityLinkedQueue ?

Rajesh Balamohan
My bad in not giving the complete details. Sorry about that..

Actually we can make use of PriorityBlockingQueue. However, this is unbounded.

There can be requirements where we need BOUNDED PriorityBlockingQueue.

ex: Throttling number of workers in a application server or servlet container or something like that.

1. Lots of requests come in and we need to prioritize them and hand it over to the ThreadPoolExecutor.
2. Problem of using PriorityBlockingQueue in this case is that, it is unbounded. However, we need to restrict the number of requests coming in, so that the "Discard Policy" of the ThreadPoolExecutor can kick in.

~Rajesh.B

On Mon, 2006-09-11 at 21:46 -0700, Hanson Char wrote:
Oops, forget about the "delay" priority.  Better to directly use j.u.c.PriorityBlockingQueue and implement Comparable for each q item.  There is still no "decrease Key" operation  in PriorityBlockingQueue though ...

H

On 9/11/06, Hanson Char <[hidden email]> wrote:
>This might be useful for creating work load with priority associated with it and submitting
> to the threadpool executor.

If you can determine the priority of each work item a priori, you can assign it an expired "delay" and place it on a j.u.c.DelayQueue.  The higher the prioirty, the further into the past a work item should be "expired".

The consumer(s) can then dequeue/process items with a priority according to their expiration.

However, if the prioirty of each work item needs to be changed after it has been placed on the queue, then this won't work as DelayQueue would ignore such changes.

It would be really nice if there is a "decrease Key" operation as Tim Peierls pointed out earlier under the email thread "Changing delays in DelayQueue ?"

Hanson

On 9/11/06, Hanson Char <[hidden email]> wrote:
Is j.u.PriorityQueue what you are looking for ?


Hanson


On 9/11/06, rbalamohan <[hidden email]> wrote:
The results look really promising.

On a similar note, I was wondering why we don't have "PRIORITY BASED LINKED QUEUE"

This might be useful for creating work load with priority associated with it and submitting to the threadpool executor.

~Rajesh.B




_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
Reply | Threaded
Open this post in threaded view
|

Re: PriorityLinkedQueue ?

Brian Goetz
> There can be requirements where we need BOUNDED PriorityBlockingQueue.

See the examples in JCiP for using a Semaphore to bound an Executor
(Listing 8.4) or a collection (Listing 5.14); you can use the same approach.

_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest