You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: include/dpp/cluster.h
+7-7
Original file line number
Diff line number
Diff line change
@@ -350,12 +350,12 @@ class DPP_EXPORT cluster {
350
350
351
351
#ifdef DPP_CORO
352
352
/**
353
-
* @brief Start a one-time timer. Use the co_await keyword on its return value to suspend the coroutine until the timer ends
354
-
*
355
-
* @param seconds How long to run the timer for
356
-
* @return awaitable<timer> co_await-able object holding the timer_handle
353
+
* @brief Get an awaitable to wait a certain amount of seconds. Use the co_await keyword on its return value to suspend the coroutine until the timer ends
354
+
*
355
+
* @param seconds How long to wait for
356
+
* @return awaitable<timer> Object that can be co_await-ed to suspend the function for a certain time
357
357
*/
358
-
awaitable<timer> co_timer(uint64_t seconds);
358
+
awaitable<timer> co_sleep(uint64_t seconds);
359
359
#endif
360
360
361
361
/**
@@ -3241,7 +3241,7 @@ class DPP_EXPORT cluster {
3241
3241
* @param callback Function to call when the API call completes.
3242
3242
* On success the callback will contain a dpp::sticker object in confirmation_callback_t::value. On failure, the value is undefined and confirmation_callback_t::is_error() method will return true. You can obtain full error details with confirmation_callback_t::get_error().
* @param callback Function to call when the API call completes.
3252
3252
* On success the callback will contain a dpp::sticker object in confirmation_callback_t::value. On failure, the value is undefined and confirmation_callback_t::is_error() method will return true. You can obtain full error details with confirmation_callback_t::get_error().
* @brief A co_await-able object handling an API call.
422
431
*
432
+
* @remark - The coroutine may be resumed in another thread, do not rely on thread_local variables.
433
+
* @warning This feature is EXPERIMENTAL. The API may change at any time and there may be bugs. Please report any to <a href="https://github.com/brainboxdotcc/DPP/issues">GitHub issues</a> or to the <a href="https://discord.gg/dpp">D++ Discord server</a>.
434
+
* @tparam ReturnType The return type of the API call. Defaults to confirmation_callback_t
* @brief Function called by the standard library when the handle is resumed. Returns the API result as an rvalue.
515
+
*/
516
+
ReturnType await_resume() {
517
+
return *std::exchange(result, std::nullopt);
518
+
}
519
+
};
520
+
521
+
/**
522
+
* @brief Overload of co_await for this object, the caller is suspended and the API call is executed. On completion the whole co_await expression evaluates to the result of the API call as an rvalue.
523
+
*
524
+
* In contrast with dpp::async, it is fine to co_await this object more than once.
525
+
*/
526
+
autooperatorco_await() constnoexcept {
527
+
return awaiter{callable};
528
+
}
529
+
};
530
+
531
+
/**
532
+
* @brief A co_await-able object handling an API call in parallel with the caller.
533
+
*
423
534
* This class is the return type of the dpp::cluster::co_* methods, but it can also be created manually to wrap any async call.
424
535
*
425
536
* @remark - This object's methods, other than constructors and operators, should not be called directly. It is designed to be used with coroutine keywords such as co_await.
@@ -428,8 +539,8 @@ namespace dpp {
428
539
* @warning This feature is EXPERIMENTAL. The API may change at any time and there may be bugs. Please report any to <a href="https://github.com/brainboxdotcc/DPP/issues">GitHub issues</a> or to the <a href="https://discord.gg/dpp">D++ Discord server</a>.
429
540
* @tparam ReturnType The return type of the API call. Defaults to confirmation_callback_t
* @brief Construct an async wrapping an awaitable, the call is made immediately by forwarding to <a href="https://en.cppreference.com/w/cpp/utility/functional/invoke">std::invoke</a> and can be awaited later to retrieve the result.
730
+
*
731
+
* @param callable The awaitable object whose API call to execute.
0 commit comments