
Hello, For the purpose of a simple game, I'm looking for a simple way to get agents communicating with each other, with agents possibly running on different threads: Basically, an agent is Agent :: * -> *, since it is parameterized with the type of messages it can receive, and can make two basic operations: fetch, which gives it the messages in its mailbox and send, which sends a message a to an Agent a Given that haskell threads are lightweight, is it reasonable to lauch a thread per agent and then implement fetch and send through Chans? It will be simple to implement and to use, but if I have, say, two hundreds of really dumb (sorry, *reactive *^^) agents, like ants, I will have to launch as many threads. I could use a neater abstraction than IO to model agents (FRP is perfect for that), but I would loose the benefits of concurrent programming (or I won't be able to keep things simple).

On Sat, Apr 2, 2011 at 11:16 AM, Yves Parès
Given that haskell threads are lightweight, is it reasonable to lauch a thread per agent and then implement fetch and send through Chans? It will be simple to implement and to use, but if I have, say, two hundreds of really dumb (sorry, reactive ^^) agents, like ants, I will have to launch as many threads.
I don't see any problems with this approach if you have only hundreds of agents, especially because GHC 7 is a lot faster when using many threads. However, if you want hundreds of thousands of agents, maybe this won't work, but I don't really know what kinds of limits GHC has 8-). That said, it may be difficult to do better than GHC's scheduler ;-). Cheers! =) -- Felipe.
participants (2)
-
Felipe Almeida Lessa
-
Yves Parès