summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2021-04-28 21:09:53 -0400
committerDavid Thompson <dthompson2@worcester.edu>2021-04-28 21:09:53 -0400
commit47fec2398a192c23424825d7ec7aacc92b6f015d (patch)
tree364fd6d21cd7711a978357de74c0db9df1782add
parent5455bb27b00108920a566bdfb4eea21b2d7e4569 (diff)
scripting: channel: Add channel-clear! procedure.
-rw-r--r--chickadee/scripting/channel.scm5
-rw-r--r--doc/api.texi4
2 files changed, 9 insertions, 0 deletions
diff --git a/chickadee/scripting/channel.scm b/chickadee/scripting/channel.scm
index edb782e..6df1313 100644
--- a/chickadee/scripting/channel.scm
+++ b/chickadee/scripting/channel.scm
@@ -84,3 +84,8 @@ script is available to retrieve the value."
(yield
(lambda (cont)
(channel-put! channel data cont))))
+
+(define (channel-clear! channel)
+ "Clear all messages and scripts awaiting messages in CHANNEL."
+ (queue-clear! (channel-get-queue channel))
+ (queue-clear! (channel-put-queue channel)))
diff --git a/doc/api.texi b/doc/api.texi
index 1d69f3d..da05e62 100644
--- a/doc/api.texi
+++ b/doc/api.texi
@@ -4512,3 +4512,7 @@ with that value.
Asynchronously send @var{data} to @var{channel} and call @var{thunk}
after it has been received.
@end deffn
+
+@deffn {Procedure} channel-clear! channel
+Clear all messages and scripts awaiting messages in @var{channel}.
+@end deffn