Ref Type: Atom

Overview

An atom is a reference type which is shared, synchronous, and autonomous:

  • shared - multiple threads can share access

  • synchronous - requested changes occur immediately

  • autonomous - changes are made to a single item

Example: Set foo to 42, right now.

Clojure API

Note: "CC" links to the official Clojure documentation; "CD" links to ClojureDocs.

  • atom (CC, CD) - creates and returns an Atom

  • compare-and-set! (CC, CD) - (maybe) set the value of Atom

  • deref (CC, CD) - returns the current state of an Atom

  • swap! (CC, CD) - swaps f(atom) into the Atom

To be continued...


This wiki page is maintained by Rich Morin, an independent consultant specializing in software design, development, and documentation. Please feel free to email comments, inquiries, suggestions, etc!

Topic revision: r6 - 21 Aug 2015, RichMorin
This site is powered by Foswiki Copyright © by the contributing authors. All material on this wiki is the property of the contributing authors.
Foswiki version v2.1.6, Release Foswiki-2.1.6, Plugin API version 2.4
Ideas, requests, problems regarding CFCL Wiki? Send us email