From 81dc08f5cad9a2aaeb92b534dfa7c404e438a9cd Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 14 Feb 2021 05:42:59 +0100 Subject: Add a usage example --- src/wait-group.lisp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/wait-group.lisp b/src/wait-group.lisp index a00c2bb..0257f9b 100644 --- a/src/wait-group.lisp +++ b/src/wait-group.lisp @@ -1,4 +1,25 @@ -;;;; TODO +;;;; Wait group provides a way to block waiting for jobs to finish. + +;;; Example: +;;; +;;; The following initialises a WebSocket client, sends a message, and waits +;;; for a response. +;;; +;;; (defvar *client* (wsd:make-client "ws://localhost:5555/")) +;;; (defvar *wg* (wait-group:make-wait-group)) +;;; +;;; (wsd:start-connection *client*) +;;; +;;; (wsd:on :message *client* #'(lambda (message) +;;; (format t "Received: ~a~%" message) +;;; (wait-group:done *wg*)) +;;; +;;; (wsd:send *client* "Sending") +;;; (wait-group:add *wg*) +;;; +;;; (wait-group:wait *wg*) +;;; +;;; (wsd:close-connection *client*) (in-package :wait-group) -- cgit v1.2.3