aboutsummaryrefslogtreecommitdiff
path: root/docs/ref/api/synch.md
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-11-09 11:40:50 -0800
committerGarrett D'Amore <garrett@damore.org>2024-11-09 11:40:50 -0800
commitbf01b3138b7e9ff109601a33627d8deee6906f20 (patch)
treebcfab94431b0c264ee5892d6940db5e39ef60808 /docs/ref/api/synch.md
parent4b25e091efe208f76802471e14452d59d10039b8 (diff)
downloadnng-bf01b3138b7e9ff109601a33627d8deee6906f20.tar.gz
nng-bf01b3138b7e9ff109601a33627d8deee6906f20.tar.bz2
nng-bf01b3138b7e9ff109601a33627d8deee6906f20.zip
Remove tabs from docs (expand to 4 spaces) - some renderers cannot cope.
Diffstat (limited to 'docs/ref/api/synch.md')
-rw-r--r--docs/ref/api/synch.md36
1 files changed, 18 insertions, 18 deletions
diff --git a/docs/ref/api/synch.md b/docs/ref/api/synch.md
index d56fb600..9ab9cc11 100644
--- a/docs/ref/api/synch.md
+++ b/docs/ref/api/synch.md
@@ -141,34 +141,34 @@ one thread (which may be chosen randomly).
### Example 1: Allocating the condition variable
```c
- nng_mtx *m;
- nng_cv *cv;
- nng_mtx_alloc(&m); // error checks elided
- nng_cv_alloc(&cv, m);
+nng_mtx *m;
+nng_cv *cv;
+nng_mtx_alloc(&m); // error checks elided
+nng_cv_alloc(&cv, m);
```
### Example 2: Waiting for the condition
```c
- expire = nng_clock() + 1000; // 1 second in the future
- nng_mtx_lock(m); // assume cv was allocated using m
- while (!condition_true) {
- if (nng_cv_until(cv, expire) == NNG_ETIMEDOUT) {
- printf("Time out reached!\n");
- break;
- }
- }
- // condition_true is true
- nng_mtx_unlock(m);
+expire = nng_clock() + 1000; // 1 second in the future
+nng_mtx_lock(m); // assume cv was allocated using m
+while (!condition_true) {
+ if (nng_cv_until(cv, expire) == NNG_ETIMEDOUT) {
+ printf("Time out reached!\n");
+ break;
+ }
+}
+// condition_true is true
+nng_mtx_unlock(m);
```
### Example 3: Signaling the condition
```c
- nng_mtx_lock(m);
- condition_true = true;
- nng_cv_wake(cv);
- nng_mtx_unlock(m);
+nng_mtx_lock(m);
+condition_true = true;
+nng_cv_wake(cv);
+nng_mtx_unlock(m);
```
{{#include ../xref.md}}