I'm trying to get a better grasp of how Agents are intended to be used, so let me give an example scenario.
Let's say I have some thing that keeps track of the state of some I/O entity, let's say some kind of file-based storage. There is state associated with the entity. It's important that only one thread be able to read or write from this storage at a time, since the state has to match what the external store's state is (say it's a cache or something). Write requests seems like a perfect match for agents, since they will be serialized and will happen asynchronously. But, what about reads. The reader needs to be able to get the result back from the read, how to do this. I can think of a few ways: - The reader passes in an atom to hold the result. After issuing the request, awaits for the agent to process the request, and then retrieves the answer from the agent. - It could use a BlockingQueue of some type to wait for the answer. In both cases, the reads run completely synchronously, waiting for their answer, and really the whole thing isn't really any better than just using locks. Or, should I rethink the whole thing, and try to represent my entire problem reactively? The essentially means converting my entire problem in to continuation-passing style, and giving some of the continuations to agents. Possible, but very pervasive. Any suggestions? Thanks, David --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---