From db322f33ba13592f2492317e3f1a070454c97059 Mon Sep 17 00:00:00 2001 From: lichao <lichao@aiotlink.com> Date: 星期四, 13 五月 2021 19:34:46 +0800 Subject: [PATCH] center alloc all msgs. --- src/sendq.cpp | 20 ++++++++++++-------- 1 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/sendq.cpp b/src/sendq.cpp index c0d5afd..36af264 100644 --- a/src/sendq.cpp +++ b/src/sendq.cpp @@ -40,20 +40,24 @@ } auto SendData = [&](Data &d) { + auto TryLoop = [&](auto &&data) { + for (int i = 0; i < 1; ++i) { + if (mq.TrySend(remote, data)) { + return true; + } + } + return false; + }; bool r = false; if (d.index() == 0) { auto &msg = boost::variant2::get<0>(pos->data().data_); - r = mq.TrySend(remote, msg); + r = TryLoop(msg); if (r) { msg.Release(); } } else { - auto &content = boost::variant2::get<1>(pos->data().data_); - MsgI msg; - if (msg.Make(content)) { - DEFER1(msg.Release();); - r = mq.TrySend(remote, msg); - } + auto command = boost::variant2::get<1>(pos->data().data_); + r = TryLoop(command); } return r; }; @@ -110,4 +114,4 @@ Collect(); return !out_.empty(); -} \ No newline at end of file +} -- Gitblit v1.8.0