summaryrefslogtreecommitdiff
path: root/ref/api/synch.html
diff options
context:
space:
mode:
Diffstat (limited to 'ref/api/synch.html')
-rw-r--r--ref/api/synch.html36
1 files changed, 18 insertions, 18 deletions
diff --git a/ref/api/synch.html b/ref/api/synch.html
index 32b155c7..80e0732b 100644
--- a/ref/api/synch.html
+++ b/ref/api/synch.html
@@ -330,28 +330,28 @@ does not depend on <em>which</em> thread will be woken. When in doubt, <code>nng
</div>
<h2 id="examples"><a class="header" href="#examples">Examples</a></h2>
<h3 id="example-1-allocating-the-condition-variable"><a class="header" href="#example-1-allocating-the-condition-variable">Example 1: Allocating the condition variable</a></h3>
-<pre><code class="language-c"> nng_mtx *m;
- nng_cv *cv;
- nng_mtx_alloc(&amp;m); // error checks elided
- nng_cv_alloc(&amp;cv, m);
+<pre><code class="language-c">nng_mtx *m;
+nng_cv *cv;
+nng_mtx_alloc(&amp;m); // error checks elided
+nng_cv_alloc(&amp;cv, m);
</code></pre>
<h3 id="example-2-waiting-for-the-condition"><a class="header" href="#example-2-waiting-for-the-condition">Example 2: Waiting for the condition</a></h3>
-<pre><code class="language-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);
+<pre><code class="language-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);
</code></pre>
<h3 id="example-3-signaling-the-condition"><a class="header" href="#example-3-signaling-the-condition">Example 3: Signaling the condition</a></h3>
-<pre><code class="language-c"> nng_mtx_lock(m);
- condition_true = true;
- nng_cv_wake(cv);
- nng_mtx_unlock(m);
+<pre><code class="language-c">nng_mtx_lock(m);
+condition_true = true;
+nng_cv_wake(cv);
+nng_mtx_unlock(m);
</code></pre>
<!-- Symbol cross reference -->
<!-- Macros -->