We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 18a872e commit 22836ffCopy full SHA for 22836ff
1 file changed
server/include/co_future.h
@@ -352,14 +352,18 @@ template <typename F>
352
auto RunCoroInThread(F &&func) -> CoFuture<std::invoke_result_t<std::decay_t<F> &>> {
353
using Func = std::decay_t<F>;
354
using T = std::invoke_result_t<Func &>;
355
- static_assert(!std::is_void_v<T>, "CoFuture<void> is not supported");
356
357
auto promise = std::make_shared<CoPromise<T>>();
358
auto future = promise->GetFuture();
359
try {
360
std::thread([promise, func = std::forward<F>(func)]() mutable {
361
362
- promise->Set(std::invoke(func));
+ if constexpr (std::is_void_v<T>) {
+ std::invoke(func);
363
+ promise->Set();
364
+ } else {
365
+ promise->Set(std::invoke(func));
366
+ }
367
} catch (...) {
368
promise->SetException(std::current_exception());
369
}
0 commit comments