mutex_protected: Add more operators
This commit is contained in:
@@ -47,6 +47,56 @@ class mutex_protected : public boost::noncopyable {
|
|||||||
return value == value_;
|
return value == value_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator!=(const mutex_protected &value) const {
|
||||||
|
QMutexLocker l(&mutex_);
|
||||||
|
return value.value() != value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const T value) const {
|
||||||
|
QMutexLocker l(&mutex_);
|
||||||
|
return value != value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator>(const mutex_protected &value) const {
|
||||||
|
QMutexLocker l(&mutex_);
|
||||||
|
return value_ > value.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator>(const T value) const {
|
||||||
|
QMutexLocker l(&mutex_);
|
||||||
|
return value_ > value;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator>=(const mutex_protected &value) const {
|
||||||
|
QMutexLocker l(&mutex_);
|
||||||
|
return value_ >= value.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator>=(const T value) const {
|
||||||
|
QMutexLocker l(&mutex_);
|
||||||
|
return value_ >= value;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator<(const mutex_protected &value) const {
|
||||||
|
QMutexLocker l(&mutex_);
|
||||||
|
return value_ < value.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator<(const T value) const {
|
||||||
|
QMutexLocker l(&mutex_);
|
||||||
|
return value_ < value;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator<=(const mutex_protected &value) const {
|
||||||
|
QMutexLocker l(&mutex_);
|
||||||
|
return value_ <= value.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator<=(const T value) const {
|
||||||
|
QMutexLocker l(&mutex_);
|
||||||
|
return value_ <= value;
|
||||||
|
}
|
||||||
|
|
||||||
void operator=(const mutex_protected &value) {
|
void operator=(const mutex_protected &value) {
|
||||||
QMutexLocker l(&mutex_);
|
QMutexLocker l(&mutex_);
|
||||||
value_ = value.value();
|
value_ = value.value();
|
||||||
@@ -62,11 +112,31 @@ class mutex_protected : public boost::noncopyable {
|
|||||||
++value_;
|
++value_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void operator+=(const T value) {
|
||||||
|
QMutexLocker l(&mutex_);
|
||||||
|
value_ += value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator+=(const mutex_protected value) {
|
||||||
|
QMutexLocker l(&mutex_);
|
||||||
|
value_ += value.value();
|
||||||
|
}
|
||||||
|
|
||||||
void operator--() {
|
void operator--() {
|
||||||
QMutexLocker l(&mutex_);
|
QMutexLocker l(&mutex_);
|
||||||
--value_;
|
--value_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void operator-=(const T value) {
|
||||||
|
QMutexLocker l(&mutex_);
|
||||||
|
value_ -= value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator-=(const mutex_protected value) {
|
||||||
|
QMutexLocker l(&mutex_);
|
||||||
|
value_ -= value.value();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T value_;
|
T value_;
|
||||||
mutable QMutex mutex_;
|
mutable QMutex mutex_;
|
||||||
|
|||||||
Reference in New Issue
Block a user