Skip to content

Commit

Permalink
fix(executor): function cannot be called
Browse files Browse the repository at this point in the history
  • Loading branch information
Serein207 committed Aug 11, 2024
1 parent 5610239 commit 96a2143
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Controller/AsyncExecutor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using Task = net::awaitable<T>;
class AsyncExecutor {
public:
AsyncExecutor(const AsyncExecutor&) = delete;
AsyncExecutor& operator==(const AsyncExecutor&) = delete;
AsyncExecutor& operator=(const AsyncExecutor&) = delete;

/**
* @param task: return value of a coroutine,
Expand Down Expand Up @@ -95,6 +95,7 @@ public:
BOOST_ASIO_COMPLETION_TOKEN_FOR(
typename net::detail::awaitable_signature<net::result_of_t<TaskFunc()>>::type)
CompletionCallback>
requires std::is_invocable_v<TaskFunc>
void asyncExecute(TaskFunc&& func,
CompletionCallback&& callback,
std::chrono::steady_clock::duration interval) {
Expand Down Expand Up @@ -149,7 +150,9 @@ private:
callback = std::forward<CompletionCallback>(callback),
this](const boost::system::error_code& ec) {
if (!ec) {
net::co_spawn(_ioc, func, [callback]() { slint::invoke_from_event_loop(callback); });
net::co_spawn(_ioc, func(), [callback]() {
slint::invoke_from_event_loop(callback);
});
asyncExecuteByTimerHelper(std::move(func), std::move(callback), taskId);
} else {
spdlog::error(ec.what());
Expand Down

0 comments on commit 96a2143

Please sign in to comment.