[Stackless] multiple channel waits
Aaron Watters
aaron at reportlab.com
Fri Aug 16 15:57:11 CEST 2002
>
>
>Sam Rushing:
>
>You would have multiple threads block waiting on a condition, and some
>other
>thread will come along and wake up one or more of them. Couldn't this
>just
>be done with a channel that waits for an integer - telling it how many
>to wake up?
>
I think it could, but you just invented "another thread". What is that
other thread doing? polling
on the condition?
I'm interested in "the inverse of broadcast" in which the recvs from 4
channels (say)
are funnelled into one channel (or handled by one task). For example
imagine a
"channel proxy socket" which looks to the outside world like a channel
generator, but
actually multiplexes data passing over a single socket to any number of
channels. How
would you implement that? (irc chat would be one application).
Using polling I might imagine the "receiver task" might look like this
loop forever
- serially check each channel for data to receive (without blocking)
- if there is some, receive the data, encode it somehow, send it over
the socket
- if none of the channels were active, sleep for a little while
This can be done with what Chris has now -- BUT it means the system is
doing a lot of pointless work even if there is little activity. Am I
missing
some other approach?
If you had "multiple socket receive" you could
loop forever
- receive from multiple socket
- encode received data somehow, send it over the socket
and you only do work when there is something to do. No polling, no sleep.
-- Aaron Watters
>
_______________________________________________
Stackless mailing list
Stackless at www.tismer.com
http://www.tismer.com/mailman/listinfo/stackless
More information about the Stackless
mailing list