diff options
| author | azevaykin <[email protected]> | 2023-10-25 10:38:53 +0300 |
|---|---|---|
| committer | azevaykin <[email protected]> | 2023-10-25 11:05:05 +0300 |
| commit | 61f7d797b4be074a20d2c902139b5f6c9725a897 (patch) | |
| tree | c236e44be8c658b54387ff9f6a682821f0d0e173 /library/cpp/actors/testlib/test_runtime.cpp | |
| parent | b82ee322906e7eec3dc912025458347b871d4ab0 (diff) | |
templated AddObserver
Diffstat (limited to 'library/cpp/actors/testlib/test_runtime.cpp')
| -rw-r--r-- | library/cpp/actors/testlib/test_runtime.cpp | 56 |
1 files changed, 37 insertions, 19 deletions
diff --git a/library/cpp/actors/testlib/test_runtime.cpp b/library/cpp/actors/testlib/test_runtime.cpp index 79de25e77f6..323e0033ea4 100644 --- a/library/cpp/actors/testlib/test_runtime.cpp +++ b/library/cpp/actors/testlib/test_runtime.cpp @@ -1201,11 +1201,20 @@ namespace NActors { isEdgeMailbox = true; TEventsList events; mbox.second->Capture(events); + + TEventsList eventsToPush; for (auto& ev : events) { TInverseGuard<TMutex> inverseGuard(Mutex); - ObserverFunc(ev); + + for (auto observer : ObserverFuncs) { + observer(ev); + if(!ev) break; + } + + if(ev && ObserverFunc(ev) != EEventAction::DROP && ev) + eventsToPush.push_back(ev); } - mbox.second->PushFront(events); + mbox.second->PushFront(eventsToPush); } if (!isEdgeMailbox) { @@ -1228,28 +1237,37 @@ namespace NActors { } hasProgress = true; - EEventAction action; + EEventAction action = EEventAction::PROCESS; { TInverseGuard<TMutex> inverseGuard(Mutex); - action = ObserverFunc(ev); + + for (auto observer : ObserverFuncs) { + observer(ev); + if(!ev) break; + } + + if (ev) + action = ObserverFunc(ev); } - switch (action) { - case EEventAction::PROCESS: - UpdateFinalEventsStatsForEachContext(*ev); - SendInternal(ev.Release(), mbox.first.NodeId - FirstNodeId, false); - break; - case EEventAction::DROP: - // do nothing - break; - case EEventAction::RESCHEDULE: { - TInstant deadline = TInstant::MicroSeconds(CurrentTimestamp) + ReschedulingDelay; - mbox.second->Freeze(deadline); - mbox.second->PushFront(ev); - break; + if (ev) { + switch (action) { + case EEventAction::PROCESS: + UpdateFinalEventsStatsForEachContext(*ev); + SendInternal(ev.Release(), mbox.first.NodeId - FirstNodeId, false); + break; + case EEventAction::DROP: + // do nothing + break; + case EEventAction::RESCHEDULE: { + TInstant deadline = TInstant::MicroSeconds(CurrentTimestamp) + ReschedulingDelay; + mbox.second->Freeze(deadline); + mbox.second->PushFront(ev); + break; + } + default: + Y_ABORT("Unknown action"); } - default: - Y_ABORT("Unknown action"); } } } |
