@@ -175,74 +175,12 @@ class Coroutine_test : public beast::unit_test::suite
175
175
BEAST_EXPECT (*lv == -1 );
176
176
}
177
177
178
- void
179
- test_yield_and_stop ()
180
- {
181
- using namespace std ::chrono_literals;
182
- using namespace jtx ;
183
-
184
- testcase (" yield and stop" );
185
-
186
- Env env (*this , envconfig ([](std::unique_ptr<Config> cfg) {
187
- cfg->FORCE_MULTI_THREAD = true ;
188
- return cfg;
189
- }));
190
-
191
- std::shared_ptr<JobQueue::Coro> c;
192
- std::mutex mutexStop;
193
- std::mutex mutexYield;
194
- std::condition_variable cond;
195
- std::condition_variable condYield;
196
- bool yielded = false ;
197
- bool stopped = false ;
198
-
199
- env.app ().getJobQueue ().postCoro (
200
- jtCLIENT, " Coroutine-Test" , [&](auto const & cr) {
201
- c = cr;
202
- {
203
- std::unique_lock lock (mutexYield);
204
- yielded = true ;
205
- condYield.notify_all ();
206
- }
207
- c->yield ();
208
- // Just to keep this job alive
209
- std::this_thread::sleep_for (5ms);
210
- });
211
- std::thread th{[&]() {
212
- std::unique_lock lock (mutexStop);
213
- cond.wait (lock, [&]() { return stopped; });
214
- // Delay a bit to wait for stop() to be called
215
- std::this_thread::sleep_for (1ms);
216
- c->post ();
217
- }};
218
-
219
- // Delay a bit to wait for yield() to be called
220
- std::this_thread::sleep_for (1ms);
221
- std::unique_lock lockYield (mutexYield);
222
- condYield.wait (lockYield, [&]() { return yielded; });
223
- {
224
- std::unique_lock lock (mutexStop);
225
- stopped = true ;
226
- cond.notify_all ();
227
- }
228
- env.app ().getJobQueue ().stop ();
229
- try
230
- {
231
- th.join ();
232
- }
233
- catch (std::exception const & e)
234
- {
235
- }
236
- pass ();
237
- }
238
-
239
178
void
240
179
run () override
241
180
{
242
181
correct_order ();
243
182
incorrect_order ();
244
183
thread_specific_storage ();
245
- // test_yield_and_stop();
246
184
}
247
185
};
248
186
0 commit comments