mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-08 22:57:52 +00:00
reduce start and stop time
This commit is contained in:
parent
7c1961d4ef
commit
0e9074aaba
@ -35,8 +35,11 @@ namespace transport
|
|||||||
|
|
||||||
void DHKeysPairSupplier::Stop ()
|
void DHKeysPairSupplier::Stop ()
|
||||||
{
|
{
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> l(m_AcquiredMutex);
|
||||||
m_IsRunning = false;
|
m_IsRunning = false;
|
||||||
m_Acquired.notify_one ();
|
m_Acquired.notify_one ();
|
||||||
|
}
|
||||||
if (m_Thread)
|
if (m_Thread)
|
||||||
{
|
{
|
||||||
m_Thread->join ();
|
m_Thread->join ();
|
||||||
@ -50,12 +53,12 @@ namespace transport
|
|||||||
while (m_IsRunning)
|
while (m_IsRunning)
|
||||||
{
|
{
|
||||||
int num, total = 0;
|
int num, total = 0;
|
||||||
while ((num = m_QueueSize - (int)m_Queue.size ()) > 0 && total < 20)
|
while ((num = m_QueueSize - (int)m_Queue.size ()) > 0 && total < 10)
|
||||||
{
|
{
|
||||||
CreateDHKeysPairs (num);
|
CreateDHKeysPairs (num);
|
||||||
total += num;
|
total += num;
|
||||||
}
|
}
|
||||||
if (total >= 20)
|
if (total >= 10)
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "Transports: ", total, " DH keys generated at the time");
|
LogPrint (eLogWarning, "Transports: ", total, " DH keys generated at the time");
|
||||||
std::this_thread::sleep_for (std::chrono::seconds(1)); // take a break
|
std::this_thread::sleep_for (std::chrono::seconds(1)); // take a break
|
||||||
@ -63,6 +66,7 @@ namespace transport
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> l(m_AcquiredMutex);
|
std::unique_lock<std::mutex> l(m_AcquiredMutex);
|
||||||
|
if (!m_IsRunning) break;
|
||||||
m_Acquired.wait (l); // wait for element gets acquired
|
m_Acquired.wait (l); // wait for element gets acquired
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user