1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 08:47:17 +01:00

Update ZMQ.hpp

This commit is contained in:
Sandu Liviu Catalin 2021-02-02 21:56:40 +02:00
parent 266e06e870
commit 3fb6005c3f

View File

@ -472,14 +472,14 @@ struct ZSkt : SqChainedInstances< ZSkt >
while (mStatus > 0)
{
using namespace std::chrono_literals;
// Wait a bit before each iteration to not exhaust resources
std::this_thread::sleep_for(50ms);
// Acquire exclusive access to the socket
std::lock_guard< std::mutex > guard(mMtx);
// Perform tasks
Recv();
Send();
SendMore();
// Perform tasks until there's none left
if (!Recv() && !Send() && !SendMore())
{
// Don't exhaust resources pointlessly
std::this_thread::sleep_for(50ms);
}
}
}
@ -557,7 +557,7 @@ protected:
/* --------------------------------------------------------------------------------------------
* Receive one message from the socket.
*/
void Recv()
bool Recv()
{
// Need someone to receive the message
ZMsg msg;
@ -566,8 +566,13 @@ protected:
// Did we have a message?
if (r >= 0)
{
mOutputQueue.enqueue(std::move(msg)); // Put it in the queue
// Put it in the queue
mOutputQueue.enqueue(std::move(msg));
// We received a message
return true;
}
// No message was retrieved
return false;
}
/* --------------------------------------------------------------------------------------------