@@ -69,24 +69,40 @@ namespace NActors {
69
69
void SimulateSleep (TDuration duration);
70
70
71
71
template <class TResult >
72
- inline TResult WaitFuture (NThreading::TFuture<TResult> f) {
72
+ inline TResult WaitFuture (NThreading::TFuture<TResult> f, TDuration simTimeout = TDuration::Max() ) {
73
73
if (!f.HasValue () && !f.HasException ()) {
74
74
TDispatchOptions options;
75
75
options.CustomFinalCondition = [&]() {
76
76
return f.HasValue () || f.HasException ();
77
77
};
78
- options.FinalEvents .emplace_back ([&](IEventHandle&) {
79
- return f.HasValue () || f.HasException ();
80
- });
78
+ // Quirk: non-empty FinalEvents enables full simulation
79
+ options.FinalEvents .emplace_back ([](IEventHandle&) { return false });
81
80
82
- this ->DispatchEvents (options);
81
+ this ->DispatchEvents (options, simTimeout );
83
82
84
83
Y_ABORT_UNLESS (f.HasValue () || f.HasException ());
85
84
}
86
85
87
86
return f.ExtractValue ();
88
87
}
89
88
89
+ template <class TCondition >
90
+ inline void WaitFor (const TString& description, const TCondition& condition, TDuration simTimeout = TDuration::Max()) {
91
+ if (!condition ()) {
92
+ TDispatchOptions options;
93
+ options.CustomFinalCondition = [&]() {
94
+ return condition ();
95
+ };
96
+ // Quirk: non-empty FinalEvents enables full simulation
97
+ options.FinalEvents .emplace_back ([](IEventHandle&) { return false ; });
98
+
99
+ Cerr << " ... waiting for " << description << Endl;
100
+ this ->DispatchEvents (options, simTimeout);
101
+
102
+ Y_ABORT_UNLESS (condition (), " Timeout while waiting for %s" , description.c_str ());
103
+ }
104
+ }
105
+
90
106
void SendToPipe (ui64 tabletId, const TActorId& sender, IEventBase* payload, ui32 nodeIndex = 0 ,
91
107
const NKikimr::NTabletPipe::TClientConfig& pipeConfig = NKikimr::NTabletPipe::TClientConfig(), TActorId clientId = TActorId(), ui64 cookie = 0, NWilson::TTraceId traceId = {});
92
108
void SendToPipe (TActorId clientId, const TActorId& sender, IEventBase* payload,
0 commit comments