[concurrency-interest] Class striped/ordered Thread Pool

David Holmes davidcholmes at aapt.net.au
Fri May 11 06:38:20 EDT 2012


So as I said, putting them in in order doesn't guarantee they actually get
processed in that order. So you either have them all served by one thread,
or your threads have to multiplex across different queues as Heinz
suggested. The end result is that processing of any given stripe is
serialized (or it may be that you can narrow down the actual code that needs
to executed in order - but somewhere you will need to "gate" things. I'm
sure there are numerous patterns for this kind of I/O processing - take a
look at the extensive work Doug Schmidt did in this area:

http://www.cs.wustl.edu/~schmidt/patterns.html

David
  -----Original Message-----
  From: concurrency-interest-bounces at cs.oswego.edu
[mailto:concurrency-interest-bounces at cs.oswego.edu]On Behalf Of Glenn
McGregor
  Sent: Friday, 11 May 2012 3:14 PM
  To: concurrency-interest at cs.oswego.edu
  Subject: Re: [concurrency-interest] Class striped/ordered Thread Pool


  On 5/10/2012 10:07 PM, David Holmes wrote:

    Not sure if this makes sense unless you use a SingleThreadExecutor per
stripeClass. Otherwise you have races in the submission of StripedRunners of
the same stripeClass, and even if you order the queue so that they start
execution in the right order, you can't guarantee what order they will
complete in. Unless it is all done by a single thread.

    David Holmes

  I can guarantee that items of the same class are generated by one thread.

  To expand on my particular use case...

  I have a small number of threads using NIO to read multiple TCP or SCTP
data streams.
  I need to process TLS in order for a given socket.
  But a given TLS stream is only read by one thread.

  So what I want to hand off my TLS work to a thread pool, but need to keep
particular streams in sequence.

  Thanks


  Glenn McGregor



      -----Original Message-----
      From: concurrency-interest-bounces at cs.oswego.edu
[mailto:concurrency-interest-bounces at cs.oswego.edu]On Behalf Of Glenn
McGregor
      Sent: Friday, 11 May 2012 2:54 PM
      To: concurrency-interest at cs.oswego.edu
      Subject: [concurrency-interest] Class striped/ordered Thread Pool


      Hello all,

      I'm looking for a thread pool with the following characteristics...
(in pseudo-code)

      interface StripedRunner {
          Object getStripeClass();
          void run();
      }

      magicPool.execute( stripedRunner );

      The idea being that any StripedRunners with the same stripeClass would
get executed in the order they were queued,
      but StripedRunners with different stripedClasses could execute
independently.

      Is there a way to configure the standard concurrent pools to work this
way (doesn't seem to be), or a way to extends
      the current code?

      Or perhaps some third party library implementation?

      Thanks!

      Glenn McGregor




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20120511/0baa1ccb/attachment.html>


More information about the Concurrency-interest mailing list