From 24f36130a66a4a3528c80f913213085e6823d40f Mon Sep 17 00:00:00 2001
From: Araq Wait groups for Nim. Wait groups for Nim.
+ Example:Procs
diff --git a/channels.html b/channels.html
index 9a756c2..fc2366a 100644
--- a/channels.html
+++ b/channels.html
@@ -382,7 +382,7 @@ Templates
diff --git a/index.html b/index.html
index a2ce484..5d38473 100644
--- a/index.html
+++ b/index.html
@@ -132,7 +132,7 @@ Index
Templates
diff --git a/theindex.html b/theindex.html
index a2ce484..5d38473 100644
--- a/theindex.html
+++ b/theindex.html
@@ -132,7 +132,7 @@ Index
diff --git a/smartptrs.html b/smartptrs.html
index 474fa72..b0e5a66 100644
--- a/smartptrs.html
+++ b/smartptrs.html
@@ -543,7 +543,7 @@
threading/waitgroups
diff --git a/waitgroups.html b/waitgroups.html
index 1aa56de..19ccb88 100644
--- a/waitgroups.html
+++ b/waitgroups.html
@@ -65,7 +65,7 @@ leave
@@ -90,7 +90,27 @@
threading/waitgroups
- import threading/waitgroups
+
+var data: array[10, int]
+var wg = createWaitGroup()
+
+proc worker(i: int) =
+ data[i] = 42
+ wg.leave()
+
+var threads: array[10, Thread[int]]
+wg.enter(10)
+for i in 0..<10:
+ createThread(threads[i], worker, i)
+
+wg.wait()
+for x in data:
+ assert x == 42
+
+joinThreads(threads)
proc enter(b: var WaitGroup; delta = 1) {.inline, ...raises: [], tags: [], ++@@ -144,9 +163,9 @@ proc enter(b: var WaitGroup; delta: Natural = 1) {.inline, ...raises: [], tags: [], forbids: [].}- Tells the WaitGroup that one or more workers (the delta parameter says how many) "entered" which means to increase the counter that counts how many workers to wait for. - Source -Edit + Tells the WaitGroup that one or more workers (the delta parameter says how many) "entered", which means to increase the counter that counts how many workers to wait for. + Source +Edit Procs
proc leave(b: var WaitGroup) {.inline, ...raises: [], tags: [], forbids: [].}- Tells the WaitGroup that one worker has finished its task. - Source -Edit + Tells the WaitGroup that one worker has finished its task. + Source +Edit