summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--starling/node.scm12
1 files changed, 10 insertions, 2 deletions
diff --git a/starling/node.scm b/starling/node.scm
index 704c2ad..4c7e56e 100644
--- a/starling/node.scm
+++ b/starling/node.scm
@@ -135,10 +135,18 @@
(class-slots class))
instance))
+(define make-id
+ (let ((n -1))
+ (lambda ()
+ (set! n (+ n 1))
+ n)))
+
(define-class <node> ()
;; Auto-generated process-unique identifier. As of now I don't see
;; a need for globally unique identifiers and this is much faster.
- (id #:getter id #:init-form (gensym "node"))
+ ;; Maybe if/when there's a serialization system this will need to be
+ ;; more robust so as to preserve ids across processes.
+ (id #:getter id #:init-thunk make-id)
;; Global index of all nodes by their unique id.
(nodes-by-id #:getter nodes-by-id #:allocation #:class
#:init-thunk make-weak-value-hash-table)
@@ -173,7 +181,7 @@
(define-method (initialize (node <node>) initargs)
(next-method)
;; Add node to global index.
- (hashq-set! (nodes-by-id node) (id node) node))
+ (hashv-set! (nodes-by-id node) (id node) node)
(define (for-each-child proc node)
(for-each proc (children node)))