@@ -342,40 +342,14 @@ class [[nodiscard("unnecessary construction")]] AwaitableScalar
342
342
std::promise<T> _promise;
343
343
};
344
344
345
- [[nodiscard (" unexpected call" )]] bool await_ready () const noexcept
345
+ [[nodiscard (" unexpected call" )]] constexpr bool await_ready () const noexcept
346
346
{
347
- return std::visit (
348
- [](const auto & value) noexcept {
349
- using value_type = std::decay_t <decltype (value)>;
350
-
351
- if constexpr (std::is_same_v<value_type, T>)
352
- {
353
- return true ;
354
- }
355
- else if constexpr (std::is_same_v<value_type, std::future<T>>)
356
- {
357
- using namespace std ::literals;
358
-
359
- return value.wait_for (0s) != std::future_status::timeout;
360
- }
361
- else if constexpr (std::is_same_v<value_type,
362
- std::shared_ptr<const response::Value>>)
363
- {
364
- return true ;
365
- }
366
- },
367
- _value);
347
+ return true ;
368
348
}
369
349
370
350
void await_suspend (std::coroutine_handle<> h) const
371
351
{
372
- std::thread (
373
- [this ](std::coroutine_handle<> h) noexcept {
374
- std::get<std::future<T>>(_value).wait ();
375
- h.resume ();
376
- },
377
- std::move (h))
378
- .detach ();
352
+ h.resume ();
379
353
}
380
354
381
355
[[nodiscard (" unnecessary construction" )]] T await_resume ()
@@ -472,35 +446,14 @@ class [[nodiscard("unnecessary construction")]] AwaitableObject
472
446
std::promise<T> _promise;
473
447
};
474
448
475
- [[nodiscard (" unexpected call" )]] bool await_ready () const noexcept
449
+ [[nodiscard (" unexpected call" )]] constexpr bool await_ready () const noexcept
476
450
{
477
- return std::visit (
478
- [](const auto & value) noexcept {
479
- using value_type = std::decay_t <decltype (value)>;
480
-
481
- if constexpr (std::is_same_v<value_type, T>)
482
- {
483
- return true ;
484
- }
485
- else if constexpr (std::is_same_v<value_type, std::future<T>>)
486
- {
487
- using namespace std ::literals;
488
-
489
- return value.wait_for (0s) != std::future_status::timeout;
490
- }
491
- },
492
- _value);
451
+ return true ;
493
452
}
494
453
495
454
void await_suspend (std::coroutine_handle<> h) const
496
455
{
497
- std::thread (
498
- [this ](std::coroutine_handle<> h) noexcept {
499
- std::get<std::future<T>>(_value).wait ();
500
- h.resume ();
501
- },
502
- std::move (h))
503
- .detach ();
456
+ h.resume ();
504
457
}
505
458
506
459
[[nodiscard (" unnecessary construction" )]] T await_resume ()
0 commit comments