remove __PICONTAINERS_SIMPLE_TYPE__

This commit is contained in:
2020-09-28 15:38:45 +03:00
parent 9dc93b73c9
commit e474c5a8de
7 changed files with 227 additions and 172 deletions

131
main.cpp
View File

@@ -1,79 +1,84 @@
#include "pip.h"
#define REGISTER_CNT (__COUNTER__)
#define REGISTER_V_STREAM_INTERNAL(T, C) \
class _VariantRegistrator_##C##__ { \
public: \
_VariantRegistrator_##C##__() { \
__VariantFunctionsBase__ * f = __VariantFunctions__<int>().instance(); \
__VariantFunctionsBase__::registered()[f->hash()] = f; \
} \
}; \
_VariantRegistrator_##C##__ __registrator_##C##__;
#define REGISTER_V_STREAM_INTERNAL_W(T, C) REGISTER_V_STREAM_INTERNAL(T, C)
#define REGISTER_V_STREAM(T) REGISTER_V_STREAM_INTERNAL_W(T, __COUNTER__)
class Send: public PIObject {
PIOBJECT(Send)
public:
Send() {piCout << "Send";}
~Send() {piCout << "~Send";}
EVENT1(ev, PIObject * , o);
struct A {
double x1;
//double x2;
};
inline PIByteArray & operator <<(PIByteArray & s, const A & a) {s << a.x1/* << a.x2*/; return s;}
inline PIByteArray & operator >>(PIByteArray & s, A & a) {s >> a.x1/* >> a.x2*/; return s;}
class Recv: public PIObject {
PIOBJECT(Recv)
public:
Recv() {piCout << "Recv";}
~Recv() {piCout << "~Recv";}
EVENT_HANDLER1(void, eh, PIObject * , o) {
piCout << "eh ..." << o;
o->deleteLater();
piMSleep(1000);
piCout << "eh ok";
struct B {
B() {
x1=0;
//x2=0;
}
B(const B & b) = default;
B & operator =(const B & b) {x1=b.x1; return *this;}
double x1;
//double x2;
};
inline PIByteArray & operator <<(PIByteArray & s, const B & a) {s << a.x1/* << a.x2*/; return s;}
inline PIByteArray & operator >>(PIByteArray & s, B & a) {s >> a.x1/* >> a.x2*/; return s;}
Send * s = new Send();
Recv * r = new Recv();
//__PIVECTOR_SIMPLE_TYPE__(B)
#include "piconditionvar.h"
int main() {
PITimeMeasurer tm;
PIByteArray ba; ba.reserve(100*100*16);
CONNECTU(s, ev, r, eh);
s->ev(r);
r->deleteLater();
s->deleteLater();
piMSleep(1500);
//s->deleteLater();
//delete o;
//eth.dump();
//versionCompare("","");
//PICloudServer s("127.0.0.1:10101");
//s.startThreadedRead();
piMSleep(10);
PIVector2D<double> vx;
PIVector2D<double> vd;
ba << vx;
ba >> vx;
vd.resize(100, 100);
vx = vd;
tm.reset();
for(int i=0; i<1000; ++i) {
vx.clear();
vx = vd;
ba << vx;
ba >> vd;
}
piCout << tm.elapsed_m();
/*PIMutex m;
PIConditionVariable var;
PIVector2D<A> ax;
PIVector2D<A> ad;
ad.resize(100, 100);
ax = ad;
tm.reset();
for(int i=0; i<1000; ++i) {
ax.clear();
ax = ad;
ba << ax;
ba >> ad;
}
piCout << tm.elapsed_m();
PIThread::runOnce([&](){
piCout << "wait ...";
m.lock();
var.wait(m);
m.unlock();
piCout << "wait done";
});
piMSleep(100);
var.notifyAll();*/
PIVector2D<B> bx;
PIVector2D<B> bd;
bd.resize(100, 100);
bx = bd;
tm.reset();
for(int i=0; i<1000; ++i) {
bx.clear();
bx = bd;
ba << bx;
ba >> bd;
}
piCout << tm.elapsed_m();
PIVector2D<complexd> cx;
PIVector2D<complexd> cd;
cd.resize(100, 100);
cx = cd;
tm.reset();
for(int i=0; i<1000; ++i) {
cx.clear();
cx = cd;
ba << cx;
ba >> cd;
}
piCout << tm.elapsed_m();
return 0;
}