version 2.8.0
new PIObject::deleteLater method decompose piobject.h to 2 files
This commit is contained in:
78
main.cpp
78
main.cpp
@@ -1,9 +1,79 @@
|
||||
#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);
|
||||
};
|
||||
|
||||
|
||||
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";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Send * s = new Send();
|
||||
Recv * r = new Recv();
|
||||
|
||||
#include "piconditionvar.h"
|
||||
int main() {
|
||||
versionCompare("","");
|
||||
PICloudServer s("127.0.0.1:10101");
|
||||
s.startThreadedRead();
|
||||
piSleep(10);
|
||||
|
||||
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);
|
||||
|
||||
/*PIMutex m;
|
||||
PIConditionVariable var;
|
||||
|
||||
PIThread::runOnce([&](){
|
||||
piCout << "wait ...";
|
||||
m.lock();
|
||||
var.wait(m);
|
||||
m.unlock();
|
||||
piCout << "wait done";
|
||||
});
|
||||
|
||||
piMSleep(100);
|
||||
var.notifyAll();*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user