API for singleton - clojure-contrib v1.3 (in development)

by Stuart Sierra

clojure-contrib is now deprecated

clojure-contrib is no longer being developed or maintained.

Rather than a single, monolithic, contributions library, Clojure now has a set of separate libraries for each unit of functionality. The libraries are in the Clojure GitHub organization at https://github.com/clojure. API documentation of the libraries can be found at https://clojure.github.io.

If you're looking for a specific function or namespace from the old clojure-contrib, see "Where Did Clojure.Contrib Go".


Full namespace name: clojure.contrib.singleton

Overview

Singleton functions

Public Variables and Functions



global-singleton

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (global-singleton f)
Returns a global singleton function.  f is a function of no
arguments that creates and returns some object.  The singleton
function will call f just once, the first time it is needed, and
cache the value for all subsequent calls.

Warning: global singletons are often unsafe in multi-threaded code.
Consider per-thread-singleton instead.
Source


per-thread-singleton

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (per-thread-singleton f)
Returns a per-thread singleton function.  f is a function of no
arguments that creates and returns some object.  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.

Warning: due to a bug in JDK 5, it may not be safe to use a
per-thread-singleton in the initialization function for another
per-thread-singleton.  See
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5025230
Source
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.