Re: Dispatcher
From: Michel (michel_at_nospam.nl)
Date: 08/11/04
- Next message: Mohamoss: "RE: Can IntPrt used in conditional statements ?"
- Previous message: Brendan Reynolds: "Re: default constraint"
- In reply to: Joris Dobbelsteen: "Dispatcher"
- Messages sorted by: [ date ] [ thread ]
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
>
>
- Next message: Mohamoss: "RE: Can IntPrt used in conditional statements ?"
- Previous message: Brendan Reynolds: "Re: default constraint"
- In reply to: Joris Dobbelsteen: "Dispatcher"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|