From 4fac0672872b9d26bca2b95d905686f98a39a8bd Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sat, 8 Aug 2020 17:41:37 -0700 Subject: [PATCH] client: monitor avoid extra wakeups --- src/clientmon.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/clientmon.cpp b/src/clientmon.cpp index f82ec32..a75d2d9 100644 --- a/src/clientmon.cpp +++ b/src/clientmon.cpp @@ -62,6 +62,8 @@ struct SubscriptionImpl : public OperationBase, public Subscription std::deque queue; uint32_t window =0u, unack =0u; + // user code has seen pop()==nullptr + bool needNotify = true; INST_COUNTER(SubscriptionImpl); @@ -80,7 +82,9 @@ struct SubscriptionImpl : public OperationBase, public Subscription log_info_printf(monevt, "Server %s channel '%s' monitor notify\n", chan->conn ? chan->conn->peerName.c_str() : "", chan->name.c_str()); - if(event) { + if(needNotify && event) { + needNotify = false; + try { event(*this); }catch(std::exception& e){ @@ -155,6 +159,8 @@ struct SubscriptionImpl : public OperationBase, public Subscription ret = std::move(ent.val); } else { + needNotify = true; + log_info_printf(monevt, "channel '%s' monitor pop() empty\n", channelName.c_str()); }