I've used agents to wrap thread-unsafe mutable Java objects with a defined life 
cycle, so that they could be used from multiple threads whilst respecting the 
life cycle.

My particular case was server-side gRPC StreamObservers for long lived client 
connections.
These are either usable, closed, or errored and an exception is thrown if you 
try to send on a closed or errored observer.

Using the agent state to model the life cycle, and the natural queueing of 
agent actions gave me thread-safe fire-and-forget semantics (which was 
appropriate for the messages involved).

To be honest it was the first time I've found a good use for agents, but they 
fit really well.

-Gordon

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to