return status from 1-item put() and get()

This commit is contained in:
Volodymyr Shymanskyy
2016-12-08 00:41:30 +02:00
parent bc9b70d301
commit bf4b89cca0

View File

@@ -32,16 +32,16 @@ public:
return s - 1; return s - 1;
} }
T put(const T& c) bool put(const T& c)
{ {
int i = _w; int i = _w;
int j = i; int j = i;
i = _inc(i); i = _inc(i);
while (i == _r) // = !writeable() if (i == _r) // !writeable()
/* nothing / just wait */; return false;
_b[j] = c; _b[j] = c;
_w = i; _w = i;
return c; return true;
} }
int put(const T* p, int n, bool t = false) int put(const T* p, int n, bool t = false)
@@ -85,14 +85,14 @@ public:
return s; return s;
} }
T get(void) bool get(T* p)
{ {
int r = _r; int r = _r;
while (r == _w) // = !readable() if (r == _w) // !readable()
/* nothing / just wait */; return false;
T t = _b[r]; *p = _b[r];
_r = _inc(r); _r = _inc(r);
return t; return true;
} }
int get(T* p, int n, bool t = false) int get(T* p, int n, bool t = false)