aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp
diff options
context:
space:
mode:
authorkruall <kruall@ydb.tech>2023-08-10 13:50:25 +0300
committerkruall <kruall@ydb.tech>2023-08-10 15:22:36 +0300
commite19e4a226b66a58f6373fbbba9b9806d1a90c465 (patch)
treed7342c37c285b4f93974befce6c911b5f5a0dba9 /library/cpp
parentc5edd93801037f77832d935319eb95cc7a1ff39f (diff)
downloadydb-e19e4a226b66a58f6373fbbba9b9806d1a90c465.tar.gz
Remove needless template argument, KIKIMR-18950
Diffstat (limited to 'library/cpp')
-rw-r--r--library/cpp/actors/core/executor_pool_basic.cpp2
-rw-r--r--library/cpp/actors/core/executor_pool_io.cpp4
-rw-r--r--library/cpp/actors/core/executor_thread.cpp21
-rw-r--r--library/cpp/actors/core/executor_thread.h6
4 files changed, 16 insertions, 17 deletions
diff --git a/library/cpp/actors/core/executor_pool_basic.cpp b/library/cpp/actors/core/executor_pool_basic.cpp
index d7d0dcfead..b27f98487f 100644
--- a/library/cpp/actors/core/executor_pool_basic.cpp
+++ b/library/cpp/actors/core/executor_pool_basic.cpp
@@ -433,9 +433,9 @@ namespace NActors {
void TBasicExecutorPool::PrepareStop() {
AtomicStore(&StopFlag, true);
for (i16 i = 0; i != PoolThreads; ++i) {
+ Threads[i].Thread->StopFlag = true;
Threads[i].Pad.Interrupt();
Threads[i].BlockedPad.Interrupt();
- AtomicStore(&Threads[i].Thread->StopFlag, TAtomic(true));
}
}
diff --git a/library/cpp/actors/core/executor_pool_io.cpp b/library/cpp/actors/core/executor_pool_io.cpp
index 539b6348b2..9e1d06c9e2 100644
--- a/library/cpp/actors/core/executor_pool_io.cpp
+++ b/library/cpp/actors/core/executor_pool_io.cpp
@@ -125,8 +125,10 @@ namespace NActors {
void TIOExecutorPool::PrepareStop() {
AtomicStore(&StopFlag, true);
- for (i16 i = 0; i != PoolThreads; ++i)
+ for (i16 i = 0; i != PoolThreads; ++i) {
+ Threads[i].Thread->StopFlag = true;
Threads[i].Pad.Interrupt();
+ }
}
void TIOExecutorPool::Shutdown() {
diff --git a/library/cpp/actors/core/executor_thread.cpp b/library/cpp/actors/core/executor_thread.cpp
index d5323785be..061ee938db 100644
--- a/library/cpp/actors/core/executor_thread.cpp
+++ b/library/cpp/actors/core/executor_thread.cpp
@@ -152,13 +152,13 @@ namespace NActors {
SafeTypeName(actorType));
}
- template <typename TMailbox, bool IsTailExecution>
- bool TExecutorThread::Execute(TMailbox* mailbox, ui32 hint) {
+ template <typename TMailbox>
+ bool TExecutorThread::Execute(TMailbox* mailbox, ui32 hint, bool isTailExecution) {
Y_VERIFY_DEBUG(DyingActors.empty());
bool reclaimAsFree = false;
- if constexpr (!IsTailExecution) {
+ if (!isTailExecution) {
Ctx.HPStart = GetCycleCountFast();
Ctx.ExecutedEvents = 0;
}
@@ -365,7 +365,7 @@ namespace NActors {
bool needToStop = false;
- auto executeActivation = [&]<bool IsTailExecution>(ui32 activation) {
+ auto executeActivation = [&](ui32 activation, bool isTailExecution) {
LWTRACK(ActivationBegin, Ctx.Orbit, Ctx.CpuId, Ctx.PoolId, Ctx.WorkerId, NHPTimer::GetSeconds(Ctx.Lease.GetPreciseExpireTs()) * 1e3);
readyActivationCount++;
if (TMailboxHeader* header = Ctx.MailboxTable->Get(activation)) {
@@ -377,7 +377,7 @@ namespace NActors {
case TMailboxType:: type: \
{ \
using TMailBox = TMailboxTable:: T ## type ## Mailbox ; \
- if (Execute<TMailBox, IsTailExecution>(static_cast<TMailBox*>(header), activation)) { \
+ if (Execute<TMailBox>(static_cast<TMailBox*>(header), activation, isTailExecution)) { \
TlsThreadContext->CapturedType = ESendingType::Lazy; \
} \
} \
@@ -421,11 +421,11 @@ namespace NActors {
Ctx.Orbit.Reset();
};
- while (!needToStop) {
+ while (!needToStop && !StopFlag.load(std::memory_order_relaxed)) {
if (TlsThreadContext->CapturedType == ESendingType::Tail) {
TlsThreadContext->CapturedType = ESendingType::Lazy;
ui32 activation = std::exchange(TlsThreadContext->CapturedActivation, 0);
- executeActivation.operator()<true>(activation);
+ executeActivation(activation, true);
continue;
}
Ctx.IsNeededToWaitNextActivation = !TlsThreadContext->CapturedActivation && !isSharedThread;
@@ -439,7 +439,7 @@ namespace NActors {
if (!activation) {
break;
}
- executeActivation.operator()<false>(activation);
+ executeActivation(activation, false);
}
}
@@ -481,7 +481,7 @@ namespace NActors {
if (pools.size() <= 1) {
ProcessExecutorPool(ExecutorPool, false);
} else {
- while (true) {
+ while (!StopFlag.load(std::memory_order_relaxed)) {
for (auto pool : pools) {
Ctx.Switch(
pool,
@@ -492,9 +492,6 @@ namespace NActors {
&Ctx.WorkerStats);
Ctx.WorkerId = -1;
ProcessExecutorPool(pool, true);
- if (RelaxedLoad(&StopFlag)) {
- return nullptr;
- }
}
}
}
diff --git a/library/cpp/actors/core/executor_thread.h b/library/cpp/actors/core/executor_thread.h
index a5aa3ed8a7..f66ffcb02d 100644
--- a/library/cpp/actors/core/executor_thread.h
+++ b/library/cpp/actors/core/executor_thread.h
@@ -76,12 +76,12 @@ namespace NActors {
void ProcessExecutorPool(IExecutorPool *pool, bool isSharedThread);
- template <typename TMailbox, bool IsTailExecution = false>
- bool Execute(TMailbox* mailbox, ui32 hint);
+ template <typename TMailbox>
+ bool Execute(TMailbox* mailbox, ui32 hint, bool isTailExecution);
public:
TActorSystem* const ActorSystem;
- TAtomic StopFlag = false;
+ std::atomic<bool> StopFlag = false;
private:
// Pool-specific