JackTrip
TestRingBuffer.h
Go to the documentation of this file.
1#ifndef __TESTRINGBUFFER__
2#define __TESTRINGBUFFER__
3
4#include "RingBuffer.h"
5#include <QThread>
6#include <iostream>
7
8static RingBuffer rb(2,100);
9
10class TestRingBufferWrite : public QThread
11{
12public:
13
14 void run()
15 {
16 int8_t* writeSlot;
17 writeSlot = new int8_t[2];
18 writeSlot[0] = *"a";
19 writeSlot[1] = *"b";
20 while (true) {
21 //std::cout << "writing BEFORE" << std::endl;
22 rb.insertSlotBlocking(writeSlot);
23 //std::cout << "writing AFTER" << std::endl;
24 }
25 }
26
27};
28
29
30class TestRingBufferRead : public QThread
31{
32public:
33
34 void run()
35 {
36 int8_t* readSlot;
37 readSlot = new int8_t[2];
38 while (true) {
39 //std::cout << "reading BEFORE" << std::endl;
40 rb.readSlotBlocking(readSlot);
41 //std::cout << "reading AFTER" << std::endl;
42 //std::cout << *(readSlot) << std::endl;
43 //std::cout << *(readSlot+1) << std::endl;
44 }
45 }
46};
47
48#endif
Provides a ring-buffer (or circular-buffer) that can be written to and read from asynchronously (bloc...
Definition: RingBuffer.h:60
void insertSlotBlocking(const int8_t *ptrToSlot)
Insert a slot into the RingBuffer from ptrToSlot. This method will block until there's space in the b...
Definition: RingBuffer.cpp:122
void readSlotBlocking(int8_t *ptrToReadSlot)
Read a slot from the RingBuffer into ptrToReadSlot. This method will block until there's space in the...
Definition: RingBuffer.cpp:145
Definition: TestRingBuffer.h:31
void run()
Definition: TestRingBuffer.h:34
Definition: TestRingBuffer.h:11
void run()
Definition: TestRingBuffer.h:14
qint8 int8_t
Typedef for unsigned long long int. This type is guaranteed to be 64-bit.
Definition: jacktrip_types.h:78