Skip to content

Commit

Permalink
misc(coro): remove long-deprecated dpp::job event handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
Mishura4 committed Jul 6, 2024
1 parent 48d1dec commit e4dc9f3
Showing 1 changed file with 3 additions and 25 deletions.
28 changes: 3 additions & 25 deletions include/dpp/event_router.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ template<class T> class event_router_t {
* saving it in a variable is recommended to avoid variable lifetime issues.
*
* @details Example: @code{cpp}
* dpp::job my_handler(dpp::slashcommand_t event) {
* dpp::task<> my_handler(const dpp::slashcommand_t& event) {
* co_await event.co_reply(dpp::message().add_component(dpp::component().add_component().set_label("click me!").set_id("test")));
*
* dpp::button_click_t b = co_await c->on_button_click.with([](const dpp::button_click_t &event){ return event.custom_id == "test"; });
Expand Down Expand Up @@ -514,7 +514,7 @@ template<class T> class event_router_t {
*
* Example:
* @details Example: @code{cpp}
* dpp::job my_handler(dpp::slashcommand_t event) {
* dpp::task<> my_handler(const dpp::slashcommand_t& event) {
* co_await event.co_reply(dpp::message().add_component(dpp::component().add_component().set_label("click me!").set_id("test")));
*
* dpp::button_click_t b = co_await c->on_message_create;
Expand Down Expand Up @@ -607,7 +607,7 @@ template<class T> class event_router_t {
* detach the listener from the event later if necessary.
*/
template <typename F>
requires (utility::callable_returns<F, dpp::job, const T&> || utility::callable_returns<F, dpp::task<void>, const T&> || utility::callable_returns<F, void, const T&>)
requires (utility::callable_returns<F, dpp::task<void>, const T&> || utility::callable_returns<F, void, const T&>)
[[maybe_unused]] event_handle operator()(F&& fun) {
return this->attach(std::forward<F>(fun));
}
Expand Down Expand Up @@ -649,28 +649,6 @@ template<class T> class event_router_t {
dispatch_container.emplace(std::piecewise_construct, std::forward_as_tuple(h), std::forward_as_tuple(std::in_place_type_t<task_handler_t>{}, std::forward<F>(fun)));
return h;
}

/**
* @brief Attach a callable to the event, adding a listener.
* The callable should either be of the form `void(const T&)` or
* `dpp::task<void>(const T&)`, where T is the event type for this event router.
*
* @deprecated dpp::job event handlers are deprecated and will be removed in a future version, use dpp::task<void> instead.
* @param fun Callable to attach to event
* @return event_handle An event handle unique to this event, used to
* detach the listener from the event later if necessary.
*/
template <typename F>
requires (utility::callable_returns<F, dpp::job, const T&>)
DPP_DEPRECATED("dpp::job event handlers are deprecated and will be removed in a future version, use dpp::task<void> instead")
[[maybe_unused]] event_handle attach(F&& fun) {
assert(dpp::utility::is_coro_enabled());

std::unique_lock l(mutex);
event_handle h = next_handle++;
dispatch_container.emplace(std::piecewise_construct, std::forward_as_tuple(h), std::forward_as_tuple(std::in_place_type_t<regular_handler_t>{}, std::forward<F>(fun)));
return h;
}
# else
/**
* @brief Attach a callable to the event, adding a listener.
Expand Down

0 comments on commit e4dc9f3

Please sign in to comment.