threadpool: make Submit return Expected instead of throwing

Unlike exceptions, which can be ignored as they require extra try-catch
blocks, returning expected errors forces callers to always handle
submission failures.

Not throwing an exception also fixes an unclean shutdown bug
#34573 since we no longer throw when attempting to Submit()
from the libevent callback http_request_cb().
This commit is contained in:
furszy
2026-02-12 14:08:22 -05:00
parent a7c29df0e5
commit 59d24bd5dd
3 changed files with 64 additions and 35 deletions

View File

@@ -87,10 +87,10 @@ FUZZ_TARGET(threadpool, .init = setup_threadpool_test) EXCLUSIVE_LOCKS_REQUIRED(
std::future<void> fut;
if (will_throw) {
expected_fail_tasks++;
fut = g_pool.Submit(ThrowTask{});
fut = *Assert(g_pool.Submit(ThrowTask{}));
} else {
expected_task_counter++;
fut = g_pool.Submit(CounterTask{task_counter});
fut = *Assert(g_pool.Submit(CounterTask{task_counter}));
}
// If caller wants to wait immediately, consume the future here (safe).