[concurrency-interest] Class striped/ordered Thread Pool
viktor.klang at gmail.com
Wed May 16 05:00:50 EDT 2012
On Wed, May 16, 2012 at 10:59 AM, Dr Heinz M. Kabutz <
heinz at javaspecialists.eu> wrote:
> On Wed, May 16, 2012 at 10:16 AM, Dr Heinz M. Kabutz <
> heinz at javaspecialists.eu> wrote:
>> 2. I've got a nice solution utilizing the SerialExecutor approach,
>> however, as Joe mentioned, shutdown is particularly challenging. I'm still
>> trying to solve that, but it is not easy.
> Executor has no shutdown ;-)
> Yeah :-) But then it is also not all that useful, as you will possibly
> have objects stuck in the queues waiting to be scheduled. How does one
> then shut down the whole construct? Answer: You don't ;-)
Let it run free!
>> 3. Another challenge, also mentioned already in this thread, is that we
>> need to carefully manage the map so that we do not get a memory leak. The
>> solution I'm trying now is to delete the SerialExecutor from the map
>> whenever it is empty. This might create a lot of objects, but at least we
>> don't have to worry about a memory leak.
> If you have the SerialExecutor extend CLQ and use a @volatile
> int/boolean to keep track of "is scheduled" or not then it's essentially
> only 2 allocations to create the SerialExecutor:
> 1 for the head-node in the CLQ and one for the SerialExecutor itself, so
> it shouldn't be that bad.
> However, the performance will of course vary depending on how it's used.
> Actually, I'm not really too worried about performance. Glenn McGregor
> was trying to solve a specific problem - that is to have his tasks execute
> in order according to a particular stripe. Thus the requirement is not to
> be particularly lock-free or low contention. In my current solution I've
> got a big fat ReentrantLock that governs everything. This way I can manage
> the shared mutable state correctly.
> Make it run, make it right, make it fast.
Yeah, I implemented the version that does remove with WRL too, it's the
easiest way to solve it.
Akka Tech Lead
Typesafe <http://www.typesafe.com/> - The software stack for applications
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Concurrency-interest