remove virtual
git-svn-id: svn://db.shs.com.ru/pip@894 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -41,7 +41,8 @@ public:
|
||||
mutex.unlock();
|
||||
other.mutex.unlock();
|
||||
}
|
||||
virtual ~PIBlockingDequeue() {
|
||||
|
||||
~PIBlockingDequeue() {
|
||||
delete cond_var_add;
|
||||
delete cond_var_rem;
|
||||
}
|
||||
@@ -51,7 +52,7 @@ public:
|
||||
*
|
||||
* @param v the element to add
|
||||
*/
|
||||
virtual void put(const T & v) {
|
||||
void put(const T & v) {
|
||||
mutex.lock();
|
||||
cond_var_rem->wait(mutex, [&]() { return PIDeque<T>::size() < max_size; });
|
||||
PIDeque<T>::push_back(v);
|
||||
@@ -66,7 +67,7 @@ public:
|
||||
* @param v the element to add
|
||||
* @return true if the element was added to this queue, else false
|
||||
*/
|
||||
virtual bool offer(const T & v) {
|
||||
bool offer(const T & v) {
|
||||
mutex.lock();
|
||||
if (PIDeque<T>::size() >= max_size) {
|
||||
mutex.unlock();
|
||||
@@ -86,7 +87,7 @@ public:
|
||||
* @param timeoutMs how long to wait before giving up, in milliseconds
|
||||
* @return true if successful, or false if the specified waiting time elapses before space is available
|
||||
*/
|
||||
virtual bool offer(const T & v, int timeoutMs) {
|
||||
bool offer(const T & v, int timeoutMs) {
|
||||
mutex.lock();
|
||||
bool isOk = cond_var_rem->waitFor(mutex, timeoutMs, [&]() { return PIDeque<T>::size() < max_size; } );
|
||||
if (isOk) PIDeque<T>::push_back(v);
|
||||
@@ -100,7 +101,7 @@ public:
|
||||
*
|
||||
* @return the head of this queue
|
||||
*/
|
||||
virtual T take() {
|
||||
T take() {
|
||||
T t;
|
||||
mutex.lock();
|
||||
cond_var_add->wait(mutex, [&]() { return !PIDeque<T>::isEmpty(); });
|
||||
@@ -118,7 +119,7 @@ public:
|
||||
* @param defaultVal value, which returns if the specified waiting time elapses before an element is available
|
||||
* @return the head of this queue, or defaultVal if the specified waiting time elapses before an element is available
|
||||
*/
|
||||
virtual T poll(int timeoutMs, const T & defaultVal) {
|
||||
T poll(int timeoutMs, const T & defaultVal) {
|
||||
T t;
|
||||
mutex.lock();
|
||||
bool isOk = cond_var_add->waitFor(mutex, timeoutMs, [&]() { return !PIDeque<T>::isEmpty(); });
|
||||
@@ -134,7 +135,7 @@ public:
|
||||
*
|
||||
* @return the capacity
|
||||
*/
|
||||
virtual size_t capacity() {
|
||||
size_t capacity() {
|
||||
size_t c;
|
||||
mutex.lock();
|
||||
c = max_size;
|
||||
@@ -148,7 +149,7 @@ public:
|
||||
*
|
||||
* @return the remaining capacity
|
||||
*/
|
||||
virtual size_t remainingCapacity() {
|
||||
size_t remainingCapacity() {
|
||||
mutex.lock();
|
||||
size_t c = max_size - PIDeque<T>::size();
|
||||
mutex.unlock();
|
||||
@@ -158,7 +159,7 @@ public:
|
||||
/**
|
||||
* @brief Returns the number of elements in this collection.
|
||||
*/
|
||||
virtual size_t size() {
|
||||
size_t size() {
|
||||
mutex.lock();
|
||||
size_t s = PIDeque<T>::size();
|
||||
mutex.unlock();
|
||||
@@ -168,7 +169,7 @@ public:
|
||||
/**
|
||||
* @brief Removes all available elements from this queue and adds them to other given queue.
|
||||
*/
|
||||
virtual size_t drainTo(PIDeque<T>& other, size_t maxCount = SIZE_MAX) {
|
||||
size_t drainTo(PIDeque<T>& other, size_t maxCount = SIZE_MAX) {
|
||||
mutex.lock();
|
||||
size_t count = maxCount > PIDeque<T>::size() ? PIDeque<T>::size() : maxCount;
|
||||
for (size_t i = 0; i < count; ++i) other.push_back(PIDeque<T>::take_front());
|
||||
@@ -179,7 +180,7 @@ public:
|
||||
/**
|
||||
* @brief Removes all available elements from this queue and adds them to other given queue.
|
||||
*/
|
||||
virtual size_t drainTo(PIBlockingDequeue<T>& other, size_t maxCount = SIZE_MAX) {
|
||||
size_t drainTo(PIBlockingDequeue<T>& other, size_t maxCount = SIZE_MAX) {
|
||||
mutex.lock();
|
||||
other.mutex.lock();
|
||||
size_t count = maxCount > PIDeque<T>::size() ? PIDeque<T>::size() : maxCount;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
class PIP_EXPORT PIConditionLock {
|
||||
public:
|
||||
explicit PIConditionLock();
|
||||
virtual ~PIConditionLock();
|
||||
~PIConditionLock();
|
||||
|
||||
//! \brief lock
|
||||
void lock();
|
||||
|
||||
@@ -15,24 +15,24 @@
|
||||
class PIP_EXPORT PIConditionVariable {
|
||||
public:
|
||||
explicit PIConditionVariable();
|
||||
virtual ~PIConditionVariable();
|
||||
~PIConditionVariable();
|
||||
|
||||
/**
|
||||
* @brief Unblocks one of the threads currently waiting for this condition. If no threads are waiting, the function
|
||||
* does nothing. If more than one, it is unspecified which of the threads is selected.
|
||||
*/
|
||||
virtual void notifyOne();
|
||||
void notifyOne();
|
||||
|
||||
/**
|
||||
* @brief Unblocks all threads currently waiting for this condition. If no threads are waiting, the function does
|
||||
* nothing.
|
||||
*/
|
||||
virtual void notifyAll();
|
||||
void notifyAll();
|
||||
|
||||
/**
|
||||
* @brief see wait(PIConditionLock&, const std::function<bool()>&)
|
||||
*/
|
||||
virtual void wait(PIConditionLock& lk);
|
||||
void wait(PIConditionLock& lk);
|
||||
|
||||
/**
|
||||
* @brief Wait until notified
|
||||
@@ -58,12 +58,12 @@ public:
|
||||
* @param condition A callable object or function that takes no arguments and returns a value that can be evaluated
|
||||
* as a bool. This is called repeatedly until it evaluates to true.
|
||||
*/
|
||||
virtual void wait(PIConditionLock& lk, const std::function<bool()>& condition);
|
||||
void wait(PIConditionLock& lk, const std::function<bool()>& condition);
|
||||
|
||||
/**
|
||||
* @brief see waitFor(PIConditionLock&, int, const std::function<bool()>&)
|
||||
*/
|
||||
virtual bool waitFor(PIConditionLock& lk, int timeoutMs);
|
||||
bool waitFor(PIConditionLock& lk, int timeoutMs);
|
||||
|
||||
/**
|
||||
* @brief Wait for timeout or until notified
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
* as a bool. This is called repeatedly until it evaluates to true.
|
||||
* @return false if timeout reached or true if wakeup condition is true
|
||||
*/
|
||||
virtual bool waitFor(PIConditionLock& lk, int timeoutMs, const std::function<bool()>& condition);
|
||||
bool waitFor(PIConditionLock& lk, int timeoutMs, const std::function<bool()>& condition);
|
||||
|
||||
private:
|
||||
NO_COPY_CLASS(PIConditionVariable)
|
||||
|
||||
Reference in New Issue
Block a user