aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--guile/starlet/state.scm8
-rw-r--r--guile/starlet/utils.scm14
2 files changed, 20 insertions, 2 deletions
diff --git a/guile/starlet/state.scm b/guile/starlet/state.scm
index 0fff383..0047014 100644
--- a/guile/starlet/state.scm
+++ b/guile/starlet/state.scm
@@ -57,7 +57,8 @@
value->number
atomically-overlay-state!
update-state!
- add-update-hook!))
+ add-update-hook!
+ state-empty?))
;; A "state" is an atomically-updating container for an immutable
@@ -452,3 +453,8 @@ pre-existing contents."
(set! selection (flatten-sublists fixture-list))))
(run-hook selection-hook selection))
+
+(define (state-empty? st)
+ (hash-table-empty?
+ (atomic-box-ref
+ (get-ht-box st))))
diff --git a/guile/starlet/utils.scm b/guile/starlet/utils.scm
index 7656827..4a2f0be 100644
--- a/guile/starlet/utils.scm
+++ b/guile/starlet/utils.scm
@@ -22,6 +22,7 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-8)
#:use-module (ice-9 exceptions)
+ #:use-module (ice-9 control)
#:export (print-hash-table
copy-hash-table
in-range
@@ -38,7 +39,8 @@
scale-and-clamp-to-range
percent->dmxval8
percent->dmxval16
- comment))
+ comment
+ hash-table-empty?))
(define (print-hash-table ht)
@@ -166,3 +168,13 @@
(syntax-rules ()
((_ body ...)
#f)))
+
+
+(define (hash-table-empty? ht)
+ (let/ec
+ return
+ (hash-for-each-handle
+ (lambda (key)
+ (return #f))
+ ht)
+ #t))