merged concurrent to main library

removed PIConditionLock, use PIMutex instead
This commit is contained in:
2020-07-30 18:50:42 +03:00
parent 4dd59132d5
commit 2ffc457566
31 changed files with 558 additions and 2176 deletions

View File

@@ -49,6 +49,9 @@ public:
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
resize(pid_size, f);
}
inline PIDeque(PIDeque<T> && other): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) {
swap(other);
}
inline virtual ~PIDeque() {
//piCout << "~PIDeque";
PIINTROSPECTION_CONTAINER_DELETE(T)
@@ -66,6 +69,12 @@ public:
return *this;
}
inline PIDeque<T> & operator =(PIDeque<T> && other) {
if (this == &other) return *this;
swap(other);
return *this;
}
typedef T value_type;
class iterator {
@@ -256,6 +265,23 @@ public:
elementNew(pid_data + pid_start + index, v);
return *this;
}
inline PIDeque<T> & insert(size_t index, T && v) {
bool dir = pid_rsize <= 2 ? true : (index >= pid_rsize / 2 ? true : false);
if (dir) {
alloc(pid_size + 1, true);
if (index < pid_size - 1) {
size_t os = pid_size - index - 1;
memmove((void*)(&(pid_data[index + pid_start + 1])), (const void*)(&(pid_data[index + pid_start])), os * sizeof(T));
}
} else {
alloc(pid_size + 1, false, -1);
if (index > 0)
memmove((void*)(&(pid_data[pid_start])), (const void*)(&(pid_data[pid_start + 1])), index * sizeof(T));
}
PIINTROSPECTION_CONTAINER_USED(T, 1)
elementNew(pid_data + pid_start + index, v);
return *this;
}
inline PIDeque<T> & insert(size_t index, const PIDeque<T> & other) {
if (other.isEmpty()) return *this;
assert(&other != this);
@@ -336,7 +362,14 @@ public:
elementNew(pid_data + pid_start + pid_size - 1, v);
return *this;
}
inline PIDeque<T> & push_back(T && v) {
alloc(pid_size + 1, true);
PIINTROSPECTION_CONTAINER_USED(T, 1);
elementNew(pid_data + pid_start + pid_size - 1, v);
return *this;
}
inline PIDeque<T> & append(const T & v) {return push_back(v);}
inline PIDeque<T> & append(T && v) {return push_back(v);}
inline PIDeque<T> & append(const PIDeque<T> & t) {
assert(&t != this);
size_t ps = pid_size;
@@ -345,6 +378,7 @@ public:
return *this;
}
inline PIDeque<T> & operator <<(const T & v) {return push_back(v);}
inline PIDeque<T> & operator <<(T && v) {return push_back(v);}
inline PIDeque<T> & operator <<(const PIDeque<T> & t) {return append(t);}
inline PIDeque<T> & push_front(const T & v) {insert(0, v); return *this;}
@@ -412,6 +446,7 @@ private:
}
}
inline void elementNew(T * to, const T & from) {new(to)T(from);}
inline void elementNew(T * to, T && from) {piSwap(*to, from);}
inline void elementDelete(T & from) {from.~T();}
inline void dealloc() {
if ((uchar*)pid_data != 0) free((uchar*)pid_data);
@@ -485,6 +520,7 @@ private:
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) = from;} \
template<> inline void PIDeque<T>::elementDelete(T &) {;} \
template<> inline PIDeque<T> & PIDeque<T>::_resizeRaw(size_t new_size) { \
if (new_size > pid_size) { \

View File

@@ -74,6 +74,7 @@ class PIMap {
public:
PIMap() {;}
PIMap(const PIMap<Key, T> & other) {*this = other;}
PIMap(PIMap<Key, T> && other) {swap(other);}
virtual ~PIMap() {;}
PIMap<Key, T> & operator =(const PIMap<Key, T> & other) {
@@ -84,6 +85,12 @@ public:
return *this;
}
PIMap<Key, T> & operator =(PIMap<Key, T> && other) {
if (this == &other) return *this;
swap(other);
return *this;
}
typedef T mapped_type;
typedef Key key_type;
typedef PIPair<Key, T> value_type;

View File

@@ -48,6 +48,9 @@ public:
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
resize(piv_size, f);
}
inline PIVector(PIVector<T> && other): piv_data(0), piv_size(0), piv_rsize(0) {
swap(other);
}
inline virtual ~PIVector() {
PIINTROSPECTION_CONTAINER_DELETE(T)
PIINTROSPECTION_CONTAINER_FREE(T, (piv_rsize))
@@ -65,6 +68,12 @@ public:
return *this;
}
inline PIVector<T> & operator =(PIVector<T> && other) {
if (this == &other) return *this;
swap(other);
return *this;
}
typedef T value_type;
class iterator {
@@ -253,6 +262,16 @@ public:
elementNew(piv_data + index, v);
return *this;
}
inline PIVector<T> & insert(size_t index, T && v) {
alloc(piv_size + 1);
if (index < piv_size - 1) {
size_t os = piv_size - index - 1;
memmove((void*)(&(piv_data[index + 1])), (const void*)(&(piv_data[index])), os * sizeof(T));
}
PIINTROSPECTION_CONTAINER_USED(T, 1)
elementNew(piv_data + index, v);
return *this;
}
inline PIVector<T> & insert(size_t index, const PIVector<T> & other) {
if (other.isEmpty()) return *this;
assert(&other != this);
@@ -320,7 +339,14 @@ public:
elementNew(piv_data + piv_size - 1, v);
return *this;
}
inline PIVector<T> & push_back(T && v) {
alloc(piv_size + 1);
PIINTROSPECTION_CONTAINER_USED(T, 1);
elementNew(piv_data + piv_size - 1, v);
return *this;
}
inline PIVector<T> & append(const T & v) {return push_back(v);}
inline PIVector<T> & append(T && v) {return push_back(v);}
inline PIVector<T> & append(const PIVector<T> & other) {
assert(&other != this);
size_t ps = piv_size;
@@ -329,6 +355,7 @@ public:
return *this;
}
inline PIVector<T> & operator <<(const T & v) {return push_back(v);}
inline PIVector<T> & operator <<(T && v) {return push_back(v);}
inline PIVector<T> & operator <<(const PIVector<T> & other) {return append(other);}
inline PIVector<T> & push_front(const T & v) {insert(0, v); return *this;}
@@ -405,6 +432,7 @@ private:
}
}
inline void elementNew(T * to, const T & from) {new(to)T(from);}
inline void elementNew(T * to, T && from) {piSwap(*to, from);}
inline void elementDelete(T & from) {from.~T();}
inline void dealloc() {
if ((uchar*)piv_data != 0) free((uchar*)piv_data);
@@ -434,6 +462,7 @@ private:
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) = from;} \
template<> inline void PIVector<T>::elementDelete(T &) {;} \
template<> inline PIVector<T> & PIVector<T>::_resizeRaw(size_t new_size) { \
if (new_size > piv_size) { \