I've found this code on <http://www.learningclojure.com/2010/11/yet-another-way-to-write-factorial.html>, but I don't understand if/how the pop-task is supposed to be threadsafe. Doesn't it allow to return twice the same head ?

```
(def to-do-list (atom '()))  
(defn add-task![t] (swap! to-do-list #(cons t %)))  
(defn pop-task![] (let [h (first @to-do-list)] (swap! to-do-list rest) h))

```

If so, is it possible to keep using atom and write the peek and swap! atomically, or is this a job for the ref mechanism ?