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

View File

@@ -209,7 +209,22 @@ public:
inline T * data(size_t index = 0) {return &(pid_data[pid_start + index]);} inline T * data(size_t index = 0) {return &(pid_data[pid_start + index]);}
inline const T * data(size_t index = 0) const {return &(pid_data[pid_start + index]);} inline const T * data(size_t index = 0) const {return &(pid_data[pid_start + index]);}
inline PIDeque<T> & clear() {resize(0); return *this;} template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline PIDeque<T> & clear() {
resize(0);
return *this;
}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline PIDeque<T> & clear() {
PIINTROSPECTION_CONTAINER_UNUSED(T, pid_size)
pid_size = 0;
return *this;
}
inline PIDeque<T> & fill(const T & f = T()) { inline PIDeque<T> & fill(const T & f = T()) {
deleteT(pid_data + pid_start, pid_size); deleteT(pid_data + pid_start, pid_size);
PIINTROSPECTION_CONTAINER_USED(T, pid_size) PIINTROSPECTION_CONTAINER_USED(T, pid_size)
@@ -218,10 +233,20 @@ public:
return *this; return *this;
} }
inline PIDeque<T> & assign(const T & f = T()) {return fill(f);} inline PIDeque<T> & assign(const T & f = T()) {return fill(f);}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline PIDeque<T> & assign(size_t new_size, const T & f) { inline PIDeque<T> & assign(size_t new_size, const T & f) {
resize(new_size); resize(new_size);
return fill(f); return fill(f);
} }
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline PIDeque<T> & assign(size_t new_size, const T & f) {
_resizeRaw(new_size);
return fill(f);
}
inline PIDeque<T> & resize(size_t new_size, const T & f = T()) { inline PIDeque<T> & resize(size_t new_size, const T & f = T()) {
if (new_size < pid_size) { if (new_size < pid_size) {
@@ -236,9 +261,18 @@ public:
} }
return *this; return *this;
} }
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline PIDeque<T> & _resizeRaw(size_t new_size) { inline PIDeque<T> & _resizeRaw(size_t new_size) {
piCout << "Error, \"resizeRaw()\" only allowed for simple type declared with __PIDEQUE_SIMPLE_TYPE__ macro!"; if (new_size > pid_size) {
assert(0); PIINTROSPECTION_CONTAINER_USED(T, (new_size-pid_size));
}
if (new_size < pid_size) {
PIINTROSPECTION_CONTAINER_UNUSED(T, (pid_size-new_size));
}
alloc(new_size, true);
return *this; return *this;
} }
@@ -437,11 +471,24 @@ private:
++t; ++t;
return (1 << t); return (1 << t);
} }
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void newT(T * dst, const T * src, size_t s) { inline void newT(T * dst, const T * src, size_t s) {
PIINTROSPECTION_CONTAINER_USED(T, s) PIINTROSPECTION_CONTAINER_USED(T, s)
for (size_t i = 0; i < s; ++i) for (size_t i = 0; i < s; ++i)
elementNew(dst + i, src[i]); elementNew(dst + i, src[i]);
} }
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void newT(T * dst, const T * src, size_t s) {
PIINTROSPECTION_CONTAINER_USED(T, s)
memcpy((void*)(dst), (const void*)(src), s * sizeof(T));
}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void deleteT(T * d, size_t sz) { inline void deleteT(T * d, size_t sz) {
PIINTROSPECTION_CONTAINER_UNUSED(T, sz) PIINTROSPECTION_CONTAINER_UNUSED(T, sz)
if ((uchar*)d != 0) { if ((uchar*)d != 0) {
@@ -449,9 +496,36 @@ private:
elementDelete(d[i]); elementDelete(d[i]);
} }
} }
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void deleteT(T * d, size_t sz) {
PIINTROSPECTION_CONTAINER_UNUSED(T, sz)
}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementNew(T * to, const T & from) {new(to)T(from);} inline void elementNew(T * to, const T & from) {new(to)T(from);}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementNew(T * to, T && from) {new(to)T(std::move(from));} inline void elementNew(T * to, T && from) {new(to)T(std::move(from));}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementNew(T1 * to, const T & from) {(*to) = from;}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementNew(T * to, T && from) {(*to) = std::move(from);}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementDelete(T & from) {from.~T();} inline void elementDelete(T & from) {from.~T();}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementDelete(T & from) {}
inline void dealloc() { inline void dealloc() {
if ((uchar*)pid_data != 0) free((uchar*)pid_data); if ((uchar*)pid_data != 0) free((uchar*)pid_data);
pid_data = 0; pid_data = 0;
@@ -520,41 +594,6 @@ private:
ssize_t pid_start; ssize_t pid_start;
}; };
#define __PIDEQUE_SIMPLE_TYPE__(T) \
template<> inline void PIDeque<T>::newT(T * dst, const T * src, size_t s) {PIINTROSPECTION_CONTAINER_USED(T, s); memcpy((void*)(dst), (const void*)(src), s * sizeof(T));} \
template<> inline void PIDeque<T>::deleteT(T *, size_t sz) {PIINTROSPECTION_CONTAINER_UNUSED(T, sz);} \
template<> inline void PIDeque<T>::elementNew(T * to, const T & from) {(*to) = from;} \
template<> inline void PIDeque<T>::elementNew(T * to, T && from) {(*to) = std::move(from);} \
template<> inline void PIDeque<T>::elementDelete(T &) {;} \
template<> inline PIDeque<T> & PIDeque<T>::_resizeRaw(size_t new_size) { \
if (new_size > pid_size) { \
PIINTROSPECTION_CONTAINER_USED(T, (new_size-pid_size)); \
} \
if (new_size < pid_size) { \
PIINTROSPECTION_CONTAINER_UNUSED(T, (pid_size-new_size)); \
} \
alloc(new_size, true); \
return *this; \
} \
template<> inline PIDeque<T> & PIDeque<T>::clear() {PIINTROSPECTION_CONTAINER_UNUSED(T, pid_size); pid_size = 0; return *this;} \
template<> inline PIDeque<T> & PIDeque<T>::assign(size_t new_size, const T & f) {_resizeRaw(new_size); return fill(f);}
__PIDEQUE_SIMPLE_TYPE__(bool)
__PIDEQUE_SIMPLE_TYPE__(char)
__PIDEQUE_SIMPLE_TYPE__(uchar)
__PIDEQUE_SIMPLE_TYPE__(short)
__PIDEQUE_SIMPLE_TYPE__(ushort)
__PIDEQUE_SIMPLE_TYPE__(int)
__PIDEQUE_SIMPLE_TYPE__(uint)
__PIDEQUE_SIMPLE_TYPE__(long)
__PIDEQUE_SIMPLE_TYPE__(ulong)
__PIDEQUE_SIMPLE_TYPE__(llong)
__PIDEQUE_SIMPLE_TYPE__(ullong)
__PIDEQUE_SIMPLE_TYPE__(float)
__PIDEQUE_SIMPLE_TYPE__(double)
__PIDEQUE_SIMPLE_TYPE__(ldouble)
#ifdef PIP_STD_IOSTREAM #ifdef PIP_STD_IOSTREAM
template<typename T> template<typename T>

View File

@@ -28,9 +28,6 @@
#include "pivector.h" #include "pivector.h"
#include "pideque.h" #include "pideque.h"
#include "pipair.h" #include "pipair.h"
# define __PICONTAINERS_SIMPLE_TYPE__(T) \
__PIDEQUE_SIMPLE_TYPE__(T)\
__PIVECTOR_SIMPLE_TYPE__(T)
template<class T> template<class T>

View File

@@ -210,7 +210,22 @@ public:
inline T * data(size_t index = 0) {return &(piv_data[index]);} inline T * data(size_t index = 0) {return &(piv_data[index]);}
inline const T * data(size_t index = 0) const {return &(piv_data[index]);} inline const T * data(size_t index = 0) const {return &(piv_data[index]);}
inline PIVector<T> & clear() {resize(0); return *this;} template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline PIVector<T> & clear() {
resize(0);
return *this;
}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline PIVector<T> & clear() {
PIINTROSPECTION_CONTAINER_UNUSED(T, piv_size)
piv_size = 0;
return *this;
}
inline PIVector<T> & fill(const T & f = T()) { inline PIVector<T> & fill(const T & f = T()) {
deleteT(piv_data, piv_size); deleteT(piv_data, piv_size);
PIINTROSPECTION_CONTAINER_USED(T, piv_size) PIINTROSPECTION_CONTAINER_USED(T, piv_size)
@@ -219,10 +234,20 @@ public:
return *this; return *this;
} }
inline PIVector<T> & assign(const T & f = T()) {return fill(f);} inline PIVector<T> & assign(const T & f = T()) {return fill(f);}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline PIVector<T> & assign(size_t new_size, const T & f) { inline PIVector<T> & assign(size_t new_size, const T & f) {
resize(new_size); resize(new_size);
return fill(f); return fill(f);
} }
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline PIVector<T> & assign(size_t new_size, const T & f) {
_resizeRaw(new_size);
return fill(f);
}
inline PIVector<T> & resize(size_t new_size, const T & f = T()) { inline PIVector<T> & resize(size_t new_size, const T & f = T()) {
if (new_size < piv_size) { if (new_size < piv_size) {
@@ -239,9 +264,17 @@ public:
} }
return *this; return *this;
} }
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline PIVector<T> & _resizeRaw(size_t new_size) { inline PIVector<T> & _resizeRaw(size_t new_size) {
piCout << "Error, \"resizeRaw()\" only allowed for simple type declared with __PIVECTOR_SIMPLE_TYPE__ macro!"; if (new_size > piv_size) {
assert(0); PIINTROSPECTION_CONTAINER_USED(T, (new_size-piv_size));
}
if (new_size < piv_size) {
PIINTROSPECTION_CONTAINER_UNUSED(T, (piv_size-new_size));
}
alloc(new_size);
return *this; return *this;
} }
inline void _copyRaw(T * dst, const T * src, size_t size) { inline void _copyRaw(T * dst, const T * src, size_t size) {
@@ -425,11 +458,24 @@ private:
while (s_ >> t) ++t; while (s_ >> t) ++t;
return (1 << t); return (1 << t);
} }
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void newT(T * dst, const T * src, size_t s) { inline void newT(T * dst, const T * src, size_t s) {
PIINTROSPECTION_CONTAINER_USED(T, s) PIINTROSPECTION_CONTAINER_USED(T, s)
for (size_t i = 0; i < s; ++i) for (size_t i = 0; i < s; ++i)
elementNew(dst + i, src[i]); elementNew(dst + i, src[i]);
} }
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void newT(T * dst, const T * src, size_t s) {
PIINTROSPECTION_CONTAINER_USED(T, s)
memcpy((void*)(dst), (const void*)(src), s * sizeof(T));
}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void deleteT(T * d, size_t sz) { inline void deleteT(T * d, size_t sz) {
PIINTROSPECTION_CONTAINER_UNUSED(T, sz) PIINTROSPECTION_CONTAINER_UNUSED(T, sz)
if ((uchar*)d != 0) { if ((uchar*)d != 0) {
@@ -437,9 +483,36 @@ private:
elementDelete(d[i]); elementDelete(d[i]);
} }
} }
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void deleteT(T * d, size_t sz) {
PIINTROSPECTION_CONTAINER_UNUSED(T, sz)
}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementNew(T * to, const T & from) {new(to)T(from);} inline void elementNew(T * to, const T & from) {new(to)T(from);}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementNew(T * to, T && from) {new(to)T(std::move(from));} inline void elementNew(T * to, T && from) {new(to)T(std::move(from));}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementNew(T1 * to, const T & from) {(*to) = from;}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementNew(T * to, T && from) {(*to) = std::move(from);}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementDelete(T & from) {from.~T();} inline void elementDelete(T & from) {from.~T();}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementDelete(T & from) {}
inline void dealloc() { inline void dealloc() {
if ((uchar*)piv_data != 0) free((uchar*)piv_data); if ((uchar*)piv_data != 0) free((uchar*)piv_data);
piv_data = 0; piv_data = 0;
@@ -464,41 +537,6 @@ private:
}; };
#define __PIVECTOR_SIMPLE_TYPE__(T) \
template<> inline void PIVector<T>::newT(T * dst, const T * src, size_t s) {PIINTROSPECTION_CONTAINER_USED(T, s); memcpy((void*)(dst), (const void*)(src), s * sizeof(T));} \
template<> inline void PIVector<T>::deleteT(T *, size_t sz) {PIINTROSPECTION_CONTAINER_UNUSED(T, sz);} \
template<> inline void PIVector<T>::elementNew(T * to, const T & from) {(*to) = from;} \
template<> inline void PIVector<T>::elementNew(T * to, T && from) {(*to) = std::move(from);} \
template<> inline void PIVector<T>::elementDelete(T &) {;} \
template<> inline PIVector<T> & PIVector<T>::_resizeRaw(size_t new_size) { \
if (new_size > piv_size) { \
PIINTROSPECTION_CONTAINER_USED(T, (new_size-piv_size)); \
} \
if (new_size < piv_size) { \
PIINTROSPECTION_CONTAINER_UNUSED(T, (piv_size-new_size)); \
} \
alloc(new_size); \
return *this; \
} \
template<> inline PIVector<T> & PIVector<T>::clear() {PIINTROSPECTION_CONTAINER_UNUSED(T, piv_size); piv_size = 0; return *this;} \
template<> inline PIVector<T> & PIVector<T>::assign(size_t new_size, const T & f) {_resizeRaw(new_size); return fill(f);}
__PIVECTOR_SIMPLE_TYPE__(bool)
__PIVECTOR_SIMPLE_TYPE__(char)
__PIVECTOR_SIMPLE_TYPE__(uchar)
__PIVECTOR_SIMPLE_TYPE__(short)
__PIVECTOR_SIMPLE_TYPE__(ushort)
__PIVECTOR_SIMPLE_TYPE__(int)
__PIVECTOR_SIMPLE_TYPE__(uint)
__PIVECTOR_SIMPLE_TYPE__(long)
__PIVECTOR_SIMPLE_TYPE__(ulong)
__PIVECTOR_SIMPLE_TYPE__(llong)
__PIVECTOR_SIMPLE_TYPE__(ullong)
__PIVECTOR_SIMPLE_TYPE__(float)
__PIVECTOR_SIMPLE_TYPE__(double)
__PIVECTOR_SIMPLE_TYPE__(ldouble)
#ifdef PIP_STD_IOSTREAM #ifdef PIP_STD_IOSTREAM
template<typename T> template<typename T>

View File

@@ -251,9 +251,13 @@ public:
piSwap<size_t>(cols_, other.cols_); piSwap<size_t>(cols_, other.cols_);
} }
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline PIVector2D<T> & _resizeRaw(size_t r, size_t c) { inline PIVector2D<T> & _resizeRaw(size_t r, size_t c) {
piCout << "Error, \"resizeRaw()\" only allowed for simple type declared with __PIVECTOR_SIMPLE_TYPE__ macro!"; rows_ = r;
assert(0); cols_ = c;
mat._resizeRaw(r*c);
return *this; return *this;
} }
@@ -287,22 +291,5 @@ inline PICout operator <<(PICout s, const PIVector2D<T> & v) {
return s; return s;
} }
#define __PIVECTOR2D_SIMPLE_TYPE__(T) \
template<> inline PIVector2D<T> & PIVector2D<T>::_resizeRaw(size_t r, size_t c) {rows_ = r; cols_ = c; mat._resizeRaw(r*c); return *this;}
__PIVECTOR2D_SIMPLE_TYPE__(bool)
__PIVECTOR2D_SIMPLE_TYPE__(char)
__PIVECTOR2D_SIMPLE_TYPE__(uchar)
__PIVECTOR2D_SIMPLE_TYPE__(short)
__PIVECTOR2D_SIMPLE_TYPE__(ushort)
__PIVECTOR2D_SIMPLE_TYPE__(int)
__PIVECTOR2D_SIMPLE_TYPE__(uint)
__PIVECTOR2D_SIMPLE_TYPE__(long)
__PIVECTOR2D_SIMPLE_TYPE__(ulong)
__PIVECTOR2D_SIMPLE_TYPE__(llong)
__PIVECTOR2D_SIMPLE_TYPE__(ullong)
__PIVECTOR2D_SIMPLE_TYPE__(float)
__PIVECTOR2D_SIMPLE_TYPE__(double)
__PIVECTOR2D_SIMPLE_TYPE__(ldouble)
#endif // PIVECTOR2D_H #endif // PIVECTOR2D_H

View File

@@ -28,7 +28,6 @@
#include "pimap.h" #include "pimap.h"
#include "pivector2d.h" #include "pivector2d.h"
__PICONTAINERS_SIMPLE_TYPE__(PIChar)
#define __PIBYTEARRAY_SIMPLE_TYPE__(T) \ #define __PIBYTEARRAY_SIMPLE_TYPE__(T) \
template<> \ template<> \

View File

@@ -47,16 +47,6 @@ const complexld complexld_i(0., 1.);
const complexld complexld_0(0.); const complexld complexld_0(0.);
const complexld complexld_1(1.); const complexld complexld_1(1.);
__PICONTAINERS_SIMPLE_TYPE__(complexi)
__PICONTAINERS_SIMPLE_TYPE__(complexs)
__PICONTAINERS_SIMPLE_TYPE__(complexf)
__PICONTAINERS_SIMPLE_TYPE__(complexd)
__PICONTAINERS_SIMPLE_TYPE__(complexld)
__PIVECTOR2D_SIMPLE_TYPE__(complexi)
__PIVECTOR2D_SIMPLE_TYPE__(complexs)
__PIVECTOR2D_SIMPLE_TYPE__(complexf)
__PIVECTOR2D_SIMPLE_TYPE__(complexd)
__PIVECTOR2D_SIMPLE_TYPE__(complexld)
__PIBYTEARRAY_SIMPLE_TYPE__(complexi) __PIBYTEARRAY_SIMPLE_TYPE__(complexi)
__PIBYTEARRAY_SIMPLE_TYPE__(complexs) __PIBYTEARRAY_SIMPLE_TYPE__(complexs)
__PIBYTEARRAY_SIMPLE_TYPE__(complexf) __PIBYTEARRAY_SIMPLE_TYPE__(complexf)

131
main.cpp
View File

@@ -1,79 +1,84 @@
#include "pip.h" #include "pip.h"
struct A {
#define REGISTER_CNT (__COUNTER__) double x1;
#define REGISTER_V_STREAM_INTERNAL(T, C) \ //double x2;
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);
}; };
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;}
struct B {
class Recv: public PIObject { B() {
PIOBJECT(Recv) x1=0;
public: //x2=0;
Recv() {piCout << "Recv";}
~Recv() {piCout << "~Recv";}
EVENT_HANDLER1(void, eh, PIObject * , o) {
piCout << "eh ..." << o;
o->deleteLater();
piMSleep(1000);
piCout << "eh ok";
} }
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;}
//__PIVECTOR_SIMPLE_TYPE__(B)
Send * s = new Send();
Recv * r = new Recv();
#include "piconditionvar.h" #include "piconditionvar.h"
int main() { int main() {
PITimeMeasurer tm;
PIByteArray ba; ba.reserve(100*100*16);
CONNECTU(s, ev, r, eh); PIVector2D<double> vx;
s->ev(r); PIVector2D<double> vd;
r->deleteLater(); ba << vx;
s->deleteLater(); ba >> vx;
piMSleep(1500); vd.resize(100, 100);
//s->deleteLater(); vx = vd;
//delete o; tm.reset();
//eth.dump(); for(int i=0; i<1000; ++i) {
//versionCompare("",""); vx.clear();
//PICloudServer s("127.0.0.1:10101"); vx = vd;
//s.startThreadedRead(); ba << vx;
piMSleep(10); ba >> vd;
}
piCout << tm.elapsed_m();
/*PIMutex m; PIVector2D<A> ax;
PIConditionVariable var; 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([&](){ PIVector2D<B> bx;
piCout << "wait ..."; PIVector2D<B> bd;
m.lock(); bd.resize(100, 100);
var.wait(m); bx = bd;
m.unlock(); tm.reset();
piCout << "wait done"; for(int i=0; i<1000; ++i) {
}); bx.clear();
bx = bd;
piMSleep(100); ba << bx;
var.notifyAll();*/ 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; return 0;
} }