Add a bunch of APNs
Fork of C027_Support by
Diff: Pipe.h
- Revision:
- 75:ce6e12067d0c
- Parent:
- 74:208e3e32d263
- Child:
- 95:8282dbbe1492
--- a/Pipe.h Thu May 15 22:20:42 2014 +0000 +++ b/Pipe.h Fri May 16 14:13:00 2014 +0000 @@ -1,4 +1,5 @@ #pragma once +#include "Relax.h" /** pipe, this class implements a buffered pipe that can be savely written and read between two context. E.g. Written from a task @@ -77,7 +78,7 @@ int j = i; i = _inc(i); while (i == _r) // = !writeable() - /*wait for space*/; + RELAX_MS(0); _b[j] = c; _w = i; return c; @@ -100,6 +101,7 @@ f = free(); if (f > 0) break; // data avail if (!t) return n - c; // no more space and not blocking + RELAX_MS(0); } // check free space if (c < f) f = c; @@ -144,7 +146,7 @@ { int r = _r; while (r == _w) // = !readable() - /*wait for data*/; + RELAX_MS(0); T t = _b[r]; _r = _inc(r); return t; @@ -167,6 +169,7 @@ f = size(); if (f) break; // free space if (!t) return n - c; // no space and not blocking + RELAX_MS(0); } // check available data if (c < f) f = c;