swh:1:snp:5c81b35c32cd128e955f4da753d99c09557a4451
Tip revision: 7e149916f56918f135b5259c3fb0b3f7119f8d07 authored by Lonca Emmanuel on 24 March 2021, 14:04:19 UTC
bumped version number to 3.0.3-dev
bumped version number to 3.0.3-dev
Tip revision: 7e14991
ConcurrentStrQueue.h
#ifndef __CONCURRENT_STR_QUEUE__
#define __CONCURRENT_STR_QUEUE__
#include <string>
#include <queue>
#include <mutex>
#include <condition_variable>
namespace CoQuiAAS {
class ConcurrentStrQueue {
public:
inline void push(std::string str) {
std::unique_lock<std::mutex> mlock(queue_mut);
elements.push(str);
mlock.unlock();
cond.notify_one();
}
inline std::string pop() {
std::unique_lock<std::mutex> mlock(queue_mut);
while (elements.empty()){
cond.wait(mlock);
}
auto item = elements.front();
elements.pop();
return item;
}
private:
std::queue<std::string> elements;
std::mutex queue_mut;
std::condition_variable cond;
};
}
#endif