MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / dataRequestFunction

Function dataRequestFunction

src/test/test_databuffer.cpp:27–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27void dataRequestFunction() {
28 std::cout << "Starting data request function..." << std::endl;
29
30 // Create and share condition variable with DataBuffer class.
31 std::mutex dataRequestMtx;
32 DataBuffer::setDataRequestCondition(&dataRequestCv);
33
34 std::cout << "Entering data request loop..." << std::endl;
35
36 while (running) {
37 // Wait for the condition to be signalled.
38 std::unique_lock<std::mutex> lk(dataRequestMtx);
39 dataRequestCv.wait(lk);
40
41 if (!running) {
42 std::cout << "Shutting down data request function..." << std::endl;
43 break;
44 }
45
46 // Write into the buffer. We use a 10 byte pattern.
47 std::string data;
48 for (uint32_t i = 0; i < 10; ++i) {
49 data.append(1, (char) lastnum++);
50 }
51
52 uint32_t wrote = DataBuffer::write(data);
53
54 std::cout << "Wrote " << wrote << " \t- ";
55 for (uint32_t i = 0; i < wrote; ++i) {
56 std::cout << (uint16_t) data[i] << " ";
57 }
58
59 std::cout << std::endl;
60
61 if (lastnum >= 100) {
62 DataBuffer::setEof(true);
63 }
64 }
65}
66
67
68int main() {

Callers

nothing calls this directly

Calls 2

waitMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected