remove virtual

git-svn-id: svn://db.shs.com.ru/pip@894 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
2020-03-04 10:56:45 +00:00
parent 9d1135f2fa
commit 659c2cd847
3 changed files with 20 additions and 19 deletions

View File

@@ -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;