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 
8 static RingBuffer rb(2,100);
9 
10 class TestRingBufferWrite : public QThread
11 {
12 public:
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 
30 class TestRingBufferRead : public QThread
31 {
32 public:
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
49 
Definition: TestRingBuffer.h:10
void run()
Definition: TestRingBuffer.h:34
Definition: TestRingBuffer.h:30
qint8 int8_t
Typedef for unsigned long long int. This type is guaranteed to be 64-bit.
Definition: jacktrip_types.h:78
void insertSlotBlocking(const int8_t *ptrToSlot)
Insert a slot into the RingBuffer from ptrToSlot. This method will block until there&#39;s space in the b...
Definition: RingBuffer.cpp:103
Provides a ring-buffer (or circular-buffer) that can be written to and read from asynchronously (bloc...
Definition: RingBuffer.h:57
void readSlotBlocking(int8_t *ptrToReadSlot)
Read a slot from the RingBuffer into ptrToReadSlot. This method will block until there&#39;s space in the...
Definition: RingBuffer.cpp:125
void run()
Definition: TestRingBuffer.h:14