Re: Dispatcher

From: Michel (michel_at_nospam.nl)
Date: 08/11/04


Date: Wed, 11 Aug 2004 11:41:34 +0200

Hi Joris,

I would say you could use a producer/consumer pattern.
The thread getting the frames puts them in some sort of queue (or more).
Each recipient lives in its own thread and is basically waiting for a
signal.
When a recipient gets a signal it checks if there is anything in the queue
for it and retrieves it or goes back to waiting mode.

In this method, all your synchronization logic will be inside the queue
(using e.g. a Monitor). It will have a method for retrieving an item
(possibly with parameters such as destination and packet index) that blocks
if there is nothing to return. It will have another method for posting an
item that notifies any blocked threads (or one if you can make the logic for
it).
As an alternative, you can create a queue for all listeners.

Hope this helps,
Michel

"Joris Dobbelsteen" <REMOVE.UPPERCASE.joris@jAoris2k.aTth.cXx> wrote in
message news:411908ff$0$147$18b6e80@news.wanadoo.nl...
> I need some thread-safe way of dispatching frames (or packets).
>
> Basically I have one thread getting the frames and it now needs to
dispatch
> these.
> Because it must not be to simple:
> Each destination (0..254) can have:
> a) none attached to it (drop the frame)
> b) a listener attached which is there to stay (needs to receive in order,
> queued)
> these come quite frequently
> c) a listener interested in a single packet and then leaves
> these come in as a response, so they are off the critical path
> This one is usually part of a send/receive cycle.
>
> Some constraints would be that:
> 1) There might be one listener per destination
> 2) Only N send/receives might be outstanding (secondary constraint, not
too
> interesting actually)...
> 3) No polling, but signalling only...
>
> I need the dispatcher to be very low-latency when dispatching. Adding /
> Removing the temporary filter is off the critical path.
>
> Anyone know a good way to archive this?
>
> - Joris
>
>



Relevant Pages

  • Re: 6.0 BETA1 if_ath problems
    ... tx queue 0, ... 110 tx frames discarded prior to association ... 26131 rx failed 'cuz of bad CRC ... 30 rx discard 'cuz mcast echo ...
    (freebsd-current)
  • Re: Architecture advise wanted.
    ... >>connections from other types of clients, pushing the data out to TCP ... >That I one reason I suggested the queue. ... >1) Create a Listener Object and put Startand Stopmethods on it. ... The Server Object will read objects from this queue. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Deallocating records with task type fields.
    ... In fact the real environment record also has a protected output queue ... passing it to the Listener with a discriminant. ... Listener to arrange for its own deallocation. ...
    (comp.lang.ada)
  • Re: Deallocating records with task type fields.
    ... In fact the real environment record also has a protected output queue ... passing it to the Listener with a discriminant. ... Listener to arrange for its own deallocation. ...
    (comp.lang.ada)
  • Re: Architecture advise wanted.
    ... > connections from other types of clients, pushing the data out to TCP ... That I one reason I suggested the queue. ... Create a Listener Object and put Startand Stopmethods on it. ... The Server Object will read objects from this queue. ...
    (microsoft.public.dotnet.languages.csharp)