
Folks, I'm trying to build an event-driven system that includes multiple event channels. I would have one channel for network events and another one for events sent by other threads. I would like to use STM and `orElse` to poll the various event channels. Is there a reasonably safe way to do this with STM and IO? The network side of things currently times out after a given number of seconds if no input is available but can also throw exceptions. I'm having a hard time figuring out how to wrap this in STM. There's another alternative that I can think of... My poker bots are launched in separate threads but do not talk to each other right now. They just receive events from the network. I would like a poker bot to tell others to stop playing and exit, for example. I guess I could build poker bots with an event loop that reads from a TChan but... I would then need twice as many threads since each bot has a socket associated with it and one thread per bot would need to read from the socket and push events into the TChan. Are there any facilities in Haskell that can poll a set of 10k descriptors and retrieve input from the first available? I don't know if I should be concerned with launching 20k threads vs. 10k threads but it seems that disassociating bots from the network has some positive effects. I could compose packets by hand in the interpreter and feed them to the TChan by hand to test individual bots, for example. Any advice is appreciated! Thanks, Joel -- http://wagerlabs.com/

Hello Joel, Sunday, November 27, 2005, 2:12:23 PM, you wrote: JR> My poker bots are launched in separate threads but do not talk to JR> each other right now. They just receive events from the network. I JR> would like a poker bot to tell others to stop playing and exit, for JR> example. use async exceptions to do it JR> 10k threads but it seems that disassociating bots from the network JR> has some positive effects. I could compose packets by hand in the JR> interpreter and feed them to the TChan by hand to test individual JR> bots, for example. as Tomasz already suggested, your bots must be parametrized by action which gets next item, not by Chan/... itself. current implementation: bot chan = ... x<-readChan chan must be: bot reading = ... x<-reading ... top_level = ... chan <- newChan forkIO $ bot (readChan chan) forkIO $ another_procedure (writeChan chan) -- Best regards, Bulat mailto:bulatz@HotPOP.com
participants (2)
-
Bulat Ziganshin
-
Joel Reymont