-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
72 lines (63 loc) · 1.6 KB
/
Copy pathmain.cpp
File metadata and controls
72 lines (63 loc) · 1.6 KB
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
#include <iostream>
#include "async.h"
#include "config.h"
#include <chrono>
#include <thread>
#define SLEEP_INTERVAL 100
//#define BYTE_BY_BYTE
int main(int, char *[])
{
std::size_t bulk = 5;
#ifdef BYTE_BY_BYTE
auto h = async::connect(bulk);
auto h2 = async::connect(bulk);
int variant = 1;
switch (variant) {
case 0:
{
std::string hData("1\n2\n3\n4\n5\n6\n{\na\nb\nc\nd\n}\n89\n");
for(char& c : hData)
{
async::receive(h, &c, 1);
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_INTERVAL));
}
std::string h2Data("1\n");
for(char& c : h2Data)
{
async::receive(h2, &c, 1);
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_INTERVAL));
}
break;
}
case 1:
{
async::receive(h,"0",1);
async::receive(h," ",1);
async::receive(h,"0",1);
async::receive(h,"\n",1);
async::receive(h,"\n",1);
async::receive(h,"1",1);
async::receive(h," ",1);
async::receive(h,"1",1);
async::receive(h,"\n",1);
async::receive(h,"2",1);
async::receive(h,"\n",1);
break;
}
default:
break;
}
async::disconnect(h);
async::disconnect(h2);
#else
auto h = async::connect(bulk);
auto h2 = async::connect(bulk);
async::receive(h, "1", 1);
async::receive(h2, "1\n", 2);
async::receive(h, "\n2\n3\n4\n5\n6\n{\na\n", 15);
async::receive(h, "b\nc\nd\n}\n89\n", 11);
async::disconnect(h);
async::disconnect(h2);
#endif
return 0;
}