transfers patch
This commit is contained in:
63
main.cpp
63
main.cpp
@@ -1,9 +1,70 @@
|
||||
#include "pip.h"
|
||||
|
||||
|
||||
|
||||
PIPeer p0("p0"), p1("p1");
|
||||
|
||||
int main() {
|
||||
|
||||
PIMap<uint, int> sends, recs;
|
||||
PISet<uint> errors, missed;
|
||||
|
||||
CONNECTL(&p0, dataReceivedEvent, ([&](const PIString & from, const PIByteArray & data){
|
||||
uint cnt = *(uint*)(data.data());
|
||||
piCout << "rec " << cnt << data.size_s();
|
||||
recs[cnt] = data.size_s();
|
||||
if (sends[cnt] != data.size_s()) {
|
||||
piCout << " " << cnt << "ERROR";
|
||||
errors << cnt;
|
||||
}
|
||||
}));
|
||||
|
||||
p0.start();
|
||||
p1.start();
|
||||
|
||||
piSleep(2);
|
||||
|
||||
int count = 10;
|
||||
for (int i = 0; i < count; ++i) {
|
||||
PIByteArray msg;
|
||||
msg << (uint)i;
|
||||
msg.enlarge(randomi() % 3800 + 4000);
|
||||
sends[i] = msg.size_s();
|
||||
piCout << "send" << i << msg.size_s();
|
||||
p1.send(p0.name(), msg);
|
||||
piMSleep(100);
|
||||
}
|
||||
|
||||
piSleep(1);
|
||||
for (int i = 0; i < count; ++i)
|
||||
if (!recs.contains(i)) missed << i;
|
||||
piCout << "errors" << errors;
|
||||
piCout << "missed" << missed;
|
||||
|
||||
|
||||
/*PIDataTransfer tr0, tr1;
|
||||
CONNECTL(&tr0, receiveFinished, ([&](bool ok){
|
||||
PIByteArray ba = tr0.data();
|
||||
uint cnt = *(uint*)(ba.data());
|
||||
piCout << "rec " << cnt << ok << ba.size_s();
|
||||
}));
|
||||
|
||||
CONNECTL(&tr1, sendRequest, ([&](PIByteArray & data){tr0.received(data);}));
|
||||
CONNECTL(&tr0, sendRequest, ([&](PIByteArray & data){tr1.received(data);}));
|
||||
|
||||
int count = 10;
|
||||
for (int i = 0; i < count; ++i) {
|
||||
PIByteArray msg;
|
||||
msg << (uint)i;
|
||||
msg.enlarge(randomi() % 3800 + 4000);
|
||||
//sends[i] = msg.size_s();
|
||||
piCout << "send" << i << msg.size_s();
|
||||
tr1.send(msg);
|
||||
//piMSleep(100);
|
||||
}*/
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
const int iters = 4;
|
||||
const int sz = 10000000;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user