Browse Source

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

v_master
Volodymyr Shymanskyy 8 years ago
parent
commit
bf4b89cca0
1 changed files with 9 additions and 9 deletions
  1. +9
    -9
      TinyGsmFifo.h

+ 9
- 9
TinyGsmFifo.h 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()
/* nothing / just wait */;
if (i == _r) // !writeable()
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()
/* nothing / just wait */;
T t = _b[r];
if (r == _w) // !readable()
return false;
*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)


Loading…
Cancel
Save