aboutsummaryrefslogtreecommitdiffstats
path: root/src/wait-group.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wait-group.lisp')
-rw-r--r--src/wait-group.lisp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/wait-group.lisp b/src/wait-group.lisp
new file mode 100644
index 0000000..35bb982
--- /dev/null
+++ b/src/wait-group.lisp
@@ -0,0 +1,27 @@
+(in-package :wait-group)
+
+(defclass wait-group ()
+ ((counter
+ :initform 0
+ :accessor counter)))
+
+(defun make-wait-group ()
+ (make-instance 'wait-group))
+
+(defgeneric add (wait-group &optional amount)
+ (:documentation ""))
+
+(defmethod add ((wait-group wait-group) &optional (amount 1))
+ (incf (counter wait-group) amount))
+
+(defgeneric done (wait-group)
+ (:documentation ""))
+
+(defmethod done ((wait-group wait-group))
+ (decf (counter wait-group)))
+
+(defgeneric wait (wait-group)
+ (:documentation ""))
+
+(defmethod wait ((wait-group wait-group))
+ (loop until (= (counter wait-group) 0)))