mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 13:27:17 +01:00
lock queue's mutex less often
This commit is contained in:
parent
ab02f722af
commit
4a5406b803
|
@ -122,16 +122,18 @@ namespace data
|
||||||
uint64_t lastProfilesCleanup = i2p::util::GetMonotonicMilliseconds (), lastObsoleteProfilesCleanup = lastProfilesCleanup;
|
uint64_t lastProfilesCleanup = i2p::util::GetMonotonicMilliseconds (), lastObsoleteProfilesCleanup = lastProfilesCleanup;
|
||||||
int16_t profilesCleanupVariance = 0, obsoleteProfilesCleanVariance = 0;
|
int16_t profilesCleanupVariance = 0, obsoleteProfilesCleanVariance = 0;
|
||||||
|
|
||||||
|
std::queue <std::shared_ptr<const I2NPMessage> > msgs;
|
||||||
while (m_IsRunning)
|
while (m_IsRunning)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto msg = m_Queue.GetNextWithTimeout (1000); // 1 sec
|
if (m_Queue.Wait (1,0)) // 1 sec
|
||||||
if (msg)
|
|
||||||
{
|
{
|
||||||
int numMsgs = 0;
|
m_Queue.GetWholeQueue (msgs);
|
||||||
while (msg)
|
while (!msgs.empty ())
|
||||||
{
|
{
|
||||||
|
auto msg = msgs.front (); msgs.pop ();
|
||||||
|
if (!msg) continue;
|
||||||
LogPrint(eLogDebug, "NetDb: Got request with type ", (int) msg->GetTypeID ());
|
LogPrint(eLogDebug, "NetDb: Got request with type ", (int) msg->GetTypeID ());
|
||||||
switch (msg->GetTypeID ())
|
switch (msg->GetTypeID ())
|
||||||
{
|
{
|
||||||
|
@ -145,9 +147,6 @@ namespace data
|
||||||
LogPrint (eLogError, "NetDb: Unexpected message type ", (int) msg->GetTypeID ());
|
LogPrint (eLogError, "NetDb: Unexpected message type ", (int) msg->GetTypeID ());
|
||||||
//i2p::HandleI2NPMessage (msg);
|
//i2p::HandleI2NPMessage (msg);
|
||||||
}
|
}
|
||||||
if (numMsgs > 100) break;
|
|
||||||
msg = m_Queue.Get ();
|
|
||||||
numMsgs++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!m_IsRunning) break;
|
if (!m_IsRunning) break;
|
||||||
|
|
|
@ -479,11 +479,11 @@ namespace tunnel
|
||||||
std::this_thread::sleep_for (std::chrono::seconds(1)); // wait for other parts are ready
|
std::this_thread::sleep_for (std::chrono::seconds(1)); // wait for other parts are ready
|
||||||
|
|
||||||
uint64_t lastTs = 0, lastPoolsTs = 0, lastMemoryPoolTs = 0;
|
uint64_t lastTs = 0, lastPoolsTs = 0, lastMemoryPoolTs = 0;
|
||||||
|
std::queue <std::shared_ptr<I2NPMessage> > msgs;
|
||||||
while (m_IsRunning)
|
while (m_IsRunning)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::queue <std::shared_ptr<I2NPMessage> > msgs;
|
|
||||||
if (m_Queue.Wait (1,0)) // 1 sec
|
if (m_Queue.Wait (1,0)) // 1 sec
|
||||||
{
|
{
|
||||||
m_Queue.GetWholeQueue (msgs);
|
m_Queue.GetWholeQueue (msgs);
|
||||||
|
|
Loading…
Reference in a new issue