Skip to content

Commit

Permalink
Improve storage documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
pashields committed Mar 23, 2014
1 parent 3e113da commit bce317f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/graf_znak/atom_storage.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns graf-znak.atom-storage
"Exposes the AtomStorage type which implements an atom backed HookStorage."
"Exposes the AtomStorage type which implements an atom backed HookStorage.
Expects pure accumulator functions."
(:require [clojure.core.typed :refer :all]
[graf-znak.hooks :refer :all]
[graf-znak.accumulators :refer :all]))
Expand Down
11 changes: 11 additions & 0 deletions src/graf_znak/concurrent_hash_storage.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
(ns graf-znak.concurrent-hash-storage
"Exposes the ConcurrentHashStorage type which implements HookStorage backed
by a java ConcurrentHashMap.
Accumulations done on this storage are not transactional. They are expected
to mutate the existing state (specified originally by the accumulators
initial state). They accumulators should be thread safe.
Generally, this storage is only advisable if performance requires it."
(:require [clojure.core.typed :refer :all]
[graf-znak.hooks :refer :all]
[graf-znak.accumulators :refer :all])
Expand All @@ -12,6 +20,8 @@
;; awful quite yet. Punting for now.
(ann ^:no-check safe-put (All [x] (Fn [ConcurrentHashMap Object (Fn [-> x]) -> x])))
(defn safe-put
"Like put if absent, but only actually loads the potential value after an
initial empty check."
[^ConcurrentHashMap hashmap key val-factory]
(when (not (.contains hashmap key))
(let [v (val-factory)]
Expand All @@ -23,6 +33,7 @@

(ann ^:no-check convert-groups (Fn [ConcurrentHashMap -> (Map Object Object)]))
(defn convert-groups
"Brings hashmap backed groups into clojure data structures."
[^ConcurrentHashMap storage]
(into {}
(map (fn>
Expand Down

0 comments on commit bce317f

Please sign in to comment.