Use an atom instead of a ref for the entity ID generation.
closes #1
author |
Steve Losh <steve@stevelosh.com> |
date |
Sat, 14 Jul 2012 14:35:05 -0400 |
parents |
180b5b981d92
|
children |
c1fba0f3ec5f
|
branches/tags |
(none) |
files |
src/caves/entities/core.clj |
Changes
--- a/src/caves/entities/core.clj Sat Jul 14 14:32:49 2012 -0400
+++ b/src/caves/entities/core.clj Sat Jul 14 14:35:05 2012 -0400
@@ -1,7 +1,7 @@
(ns caves.entities.core)
-(def ids (ref 0))
+(def ids (atom 0))
(defprotocol Entity
(tick [this world]
@@ -9,10 +9,7 @@
(defn get-id []
- (dosync
- (let [id @ids]
- (alter ids inc)
- id)))
+ (swap! ids inc))
(defn make-fnmap