29 lines
757 B
C
29 lines
757 B
C
|
/*************************************************************************
|
||
|
> File Name: CMessageQueue.h
|
||
|
> Author: SongTL
|
||
|
> Mail: songtianlun@comleader.com.cn
|
||
|
> Created Time: 2020年07月21日 星期二 16时46分37秒
|
||
|
************************************************************************/
|
||
|
|
||
|
#ifndef CMESSAGEQUEUE_H
|
||
|
#define CMESSAGEQUEUE_H
|
||
|
|
||
|
template<class Type>
|
||
|
class ConcurrentQueue
|
||
|
{
|
||
|
ConcurrentQueue& operator = (const ConcurrentQueue&) = delete;
|
||
|
ConcurrentQueue(const ConcurrentQueue& other) = delete;
|
||
|
|
||
|
public:
|
||
|
ConcurrentQueue() : _queue(), _mutex(), _condition() {}
|
||
|
virtual ~ConcurrentQueue() {}
|
||
|
|
||
|
void Push(Type record)
|
||
|
{
|
||
|
std::lock_guard <std::mutex> lock(_mutex);
|
||
|
_queue.push(record);
|
||
|
_condition.notify_one();
|
||
|
}
|
||
|
}
|
||
|
#endif
|