Skip to content

Commit 22836ff

Browse files
committed
small fixes
1 parent 18a872e commit 22836ff

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

server/include/co_future.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,14 +352,18 @@ template <typename F>
352352
auto RunCoroInThread(F &&func) -> CoFuture<std::invoke_result_t<std::decay_t<F> &>> {
353353
using Func = std::decay_t<F>;
354354
using T = std::invoke_result_t<Func &>;
355-
static_assert(!std::is_void_v<T>, "CoFuture<void> is not supported");
356355

357356
auto promise = std::make_shared<CoPromise<T>>();
358357
auto future = promise->GetFuture();
359358
try {
360359
std::thread([promise, func = std::forward<F>(func)]() mutable {
361360
try {
362-
promise->Set(std::invoke(func));
361+
if constexpr (std::is_void_v<T>) {
362+
std::invoke(func);
363+
promise->Set();
364+
} else {
365+
promise->Set(std::invoke(func));
366+
}
363367
} catch (...) {
364368
promise->SetException(std::current_exception());
365369
}

0 commit comments

Comments
 (0)