summaryrefslogtreecommitdiff
path: root/starling/node.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2021-04-14 20:58:42 -0400
committerDavid Thompson <dthompson2@worcester.edu>2021-04-14 20:59:05 -0400
commitf830bbd48213d236429201741edd6ec70e7053f9 (patch)
tree6ab1a8892dc9bfb39bff7d557834ba8289799f74 /starling/node.scm
parent91d6b335df7ba05add0335c144582c36e01b32a4 (diff)
node: Change id system to a numeric one.
Diffstat (limited to 'starling/node.scm')
-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)))