add idempotent wakeup for flushing instead of the dumb queue checking

pull/1658/head
Jeff Becker 3 years ago
parent e2bdf8792b
commit f9e0c8f50c
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -21,17 +21,16 @@ namespace llarp
, m_Endpoint(ep)
, createdAt(ep->Now())
, m_SendQueue(SendContextQueueSize)
{}
{
m_FlushWakeup = ep->Loop()->make_waker([this] { FlushUpstream(); });
}
bool
SendContext::Send(std::shared_ptr<ProtocolFrame> msg, path::Path_ptr path)
{
if (not path->IsReady())
return false;
if (m_SendQueue.empty() or m_SendQueue.full())
{
m_Endpoint->Loop()->call_soon([this] { FlushUpstream(); });
}
m_FlushWakeup->Trigger();
return m_SendQueue.tryPushBack(std::make_pair(
std::make_shared<routing::PathTransferMessage>(*msg, remoteIntro.pathID), path))
== thread::QueueReturn::Success;

@ -56,6 +56,8 @@ namespace llarp
std::function<void(AuthResult)> authResultListener;
std::shared_ptr<EventLoopWakeup> m_FlushWakeup;
virtual bool
ShiftIntroduction(bool rebuild = true)
{

Loading…
Cancel
Save