-
Notifications
You must be signed in to change notification settings - Fork 2
/
test2.cpp
99 lines (77 loc) · 2.04 KB
/
test2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "test2.h"
Test2::Test2() {
a.RegisterSink(&b);
b.RegisterSource(&a);
c.RegisterSource(&a);
c.RegisterSource(&b);
a.RegisterSink(&c);
b.RegisterSink(&c);
a.Preallocate();
b.Preallocate();
c.Preallocate();
StopWatch stop_watch;
a.SetStopWatch(&stop_watch);
b.SetStopWatch(&stop_watch);
c.SetStopWatch(&stop_watch);
}
Test2::~Test2() { }
void NodeAT2::Run() {
int j = 0;
while (true) {
auto b = (AcquireBuffer());
auto xx = GetBufferConfig();
b->GetData()[0] = j;
for (int x = 1; x < xx->frames * xx->channels; x++) {
b->GetData()[x] = x;
}
atomic_thread_fence(memory_order_seq_cst);
b->GetData()[1] = 1;
j++;
atomic_thread_fence(memory_order_seq_cst);
PushBuffer(b);
_stop_watch->Reset();
}
}
void NodeBT2::Run() {
int j = 0;
while (true) {
auto b = AcquireBuffer();
auto xx = GetBufferConfig();
auto bb = PeakAllSources();
if (j != bb[0]->GetData()[0]) {
std::cout << "fail" << endl;
while (1) {
}
}
j++;
for (int x = 1; x < xx->frames * xx->channels; x++) {
b->GetData()[x] = bb[0]->GetData()[x] - x;
}
atomic_thread_fence(memory_order_seq_cst);
PushBuffer(b);
atomic_thread_fence(memory_order_seq_cst);
ReleaseAllSources(bb);
}
}
void NodeCT2::Run() {
int j = 0;
while (true) {
auto bb = PeakAllSources();
auto xx = GetBufferConfig();
if (j != bb[0]->GetData()[0]) {
std::cout << "fail" << endl;
while (1) {
}
}
j++;
for (int x = 1; x < xx->frames * xx->channels; x++) {
if (bb[0]->GetData()[x] != x || bb[1]->GetData()[x] != 0) {
std::cout << "fail" << endl;
while (1) {
}
}
}
atomic_thread_fence(memory_order_seq_cst);
ReleaseAllSources(bb);
}
}