Skip to content

Commit cde3445

Browse files
committed
ai min: MtQ
1 parent c907ec7 commit cde3445

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/thread/MtInQueue.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44
* SPDX-License-Identifier: BSD-3-Clause
55
*/
66
// ***********************************************************************************************
7-
#include <thread>
8-
#include <utility>
9-
10-
#include "MT_PingMainTH.hpp"
117
#include "MtInQueue.hpp"
8+
#include "MT_PingMainTH.hpp"
129

1310
using namespace std;
1411

src/thread/MtInQueue.hpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,10 @@ bool MtInQueue::setHdlrOK(const EleHdlr& aHdlr) noexcept
141141
return false;
142142
}
143143

144-
auto&& tid = std::type_index(typeid(aEleType));
145-
if (tid_hdlr_S_.find(tid) != tid_hdlr_S_.end())
146-
{
144+
auto [_, ok] = tid_hdlr_S_.try_emplace(std::type_index(typeid(aEleType)), aHdlr);
145+
if (!ok)
147146
ERR("(MtQ) failed!!! overwrite hdlr may unsafe existing data");
148-
return false;
149-
}
150-
151-
tid_hdlr_S_.emplace(tid, aHdlr); // except eg bad_alloc: can't recover->terminate
152-
return true;
147+
return ok;
153148
}
154149

155150

0 commit comments

Comments
 (0)