MCPcopy Create free account
hub / github.com/andreasfertig/programming-with-cpp20 / main

Function main

02.10-coroutineParsingDataStream0/main.cpp:250–275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

248}
249
250int main()
251{
252 std::vector<byte> fakeBytes1{
253 0x70_B, ESC, SOF, ESC,
254 'H'_B, 'e'_B, 'l'_B, 'l'_B, 'o'_B, ESC, SOF,
255 0x7_B, ESC, SOF};
256
257// #A Simulate the first network stream
258auto stream1 = sender(std::move(fakeBytes1));
259
260// #B Create the Parse coroutine and store the handle in p
261auto p = Parse();
262
263ProcessStream(stream1, p); // #C Process the bytes
264
265// #D Simulate the reopening of the network stream
266std::vector<byte> fakeBytes2{
267 'W'_B, 'o'_B, 'r'_B, 'l'_B, 'd'_B, ESC, SOF, 0x99_B};
268
269// #E Simulate a second network stream
270auto stream2 = sender(std::move(fakeBytes2));
271
272// #F We still use the former p and feed it with new bytes
273ProcessStream(stream2, p);
274
275}

Callers

nothing calls this directly

Calls 4

moveFunction · 0.85
ProcessStreamFunction · 0.85
senderFunction · 0.70
ParseFunction · 0.70

Tested by

no test coverage detected