[IPC] Experimental second handler
This commit is contained in:
parent
20139d4a52
commit
f81f820b47
@ -9,13 +9,16 @@ namespace Utils
|
||||
if(this->remove) boost::interprocess::message_queue::remove(this->name.data());
|
||||
queue.reset(new boost::interprocess::message_queue(boost::interprocess::open_or_create, this->name.data(), _queueSize, _bufferSize + sizeof(Channel::Header)));
|
||||
|
||||
this->queueThread = std::thread(&Channel::queueWorker, this);
|
||||
this->queueThread = std::thread(&Channel::queueWorker2, this);
|
||||
}
|
||||
|
||||
Channel::~Channel()
|
||||
{
|
||||
this->terminateQueue = true;
|
||||
this->queueEvent.notify_all();
|
||||
{
|
||||
std::lock_guard<std::mutex> _(this->queueMutex);
|
||||
this->terminateQueue = true;
|
||||
this->queueEvent.notify_all();
|
||||
}
|
||||
|
||||
if(this->queueThread.joinable())
|
||||
{
|
||||
@ -110,6 +113,25 @@ namespace Utils
|
||||
}
|
||||
}
|
||||
|
||||
void Channel::queueWorker2()
|
||||
{
|
||||
while (!this->terminateQueue)
|
||||
{
|
||||
if(!this->internalQueue.empty())
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->queueMutex);
|
||||
|
||||
std::string data = this->internalQueue.front();
|
||||
if(this->queue->try_send(data.data(), data.size(), 0))
|
||||
{
|
||||
this->internalQueue.pop();
|
||||
}
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(1000us);
|
||||
}
|
||||
}
|
||||
|
||||
void Channel::queueWorker()
|
||||
{
|
||||
while (!this->terminateQueue)
|
||||
|
@ -47,6 +47,7 @@ namespace Utils
|
||||
|
||||
void enqueueMessage(std::string data);
|
||||
void queueWorker();
|
||||
void queueWorker2();
|
||||
|
||||
bool terminateQueue;
|
||||
std::condition_variable queueEvent;
|
||||
|
Loading…
Reference in New Issue
Block a user