A better version of clojure.contrib.singleton:

clojure.contrib.singleton/per-thread-singleton
([f])
  Returns a per-thread singleton function.  The singleton
  function will call f only once for each thread, and cache its value
  for subsequent calls from the same thread.  This allows you to
  safely and lazily initialize shared objects on a per-thread basis.

clojure.contrib.singleton/global-singleton
([f])
  Returns a global singleton function.


per-thread-singleton is implemented using java.lang.ThreadLocal, which
has an edge-case bug up to JDK 5:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5025230

-Stuart Sierra
--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to