mireo/async-mqtt5

executor_type/get_executor

Closed this issue · 1 comments

With boost 1.86 some tokens (namely cancel_at and cancel_after) and the partial tokens use the associated_executor from the initiation object. This allows the following:

c.async_publish<async_mqtt5::qos_e::at_most_once>(
		"<topic>", "Hello world!",
		async_mqtt5::retain_e::no, async_mqtt5::publish_props {},
		asio::cancel_after([&c](async_mqtt5::error_code ec) {
			std::cout << ec.message() << std::endl;
			c.async_disconnect(boost::asio::detached); // disconnect and close the client
		}, std::chrono::milliseconds(100)));
	);

it will also allow partial tokens, e.g. the following:

auto [ec] = co_await c.async_publish<async_mqtt5::qos_e::at_most_once>(
		"<topic>", "Hello world!",
		async_mqtt5::retain_e::no, async_mqtt5::publish_props {}, asio::as_tuple);

std::cout << ec.message() << std::endl;

Resolved with 40b1f7e.