mirror of https://github.com/ARMmbed/mbed-os.git
vodafone: non blocking circular buffer
parent
a7d3226554
commit
da778bd931
|
@ -55,19 +55,13 @@ public:
|
||||||
void queue(T k)
|
void queue(T k)
|
||||||
{
|
{
|
||||||
mtx.lock();
|
mtx.lock();
|
||||||
while (((write + 1) % size) == read) //if (isFull())
|
|
||||||
{
|
|
||||||
/*while((((write + 1) % size) == read))
|
|
||||||
{*/
|
|
||||||
mtx.unlock();
|
|
||||||
Thread::wait(10);
|
|
||||||
mtx.lock();
|
|
||||||
/*}*/
|
|
||||||
//read++;
|
|
||||||
//read %= size;
|
|
||||||
}
|
|
||||||
buf[write++] = k;
|
buf[write++] = k;
|
||||||
write %= size;
|
write %= size;
|
||||||
|
if (isFull())
|
||||||
|
{
|
||||||
|
read++;
|
||||||
|
read %= size;
|
||||||
|
}
|
||||||
mtx.unlock();
|
mtx.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue