You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
there is no bug, you just misused the library :)
You block in the threadpool and it is very wrong
from the documentation:
Waiting for a result to finish is a blocking operation (in the case the asynchronous result is not ready), and will suspend the entire thread of execution waiting for the asynchronous result to become available. Waiting operations are generally discouraged and only allowed in root-level tasks or in contexts which allow it, like blocking the main thread waiting for the rest of the application to finish gracefully, or using concurrencpp::blocking_executor or concurrencpp::thread_executor.
we are using a parallel coroutine, to avoid returning result<result<void>> (and having to co_await co_await later on), and we use co_await inside the threadpool to avoid blocking.
Note that blocking in the main thread (result.get();) is ok, because we are waiting for our "real" application to finish. in any other case we need co_await, otherwise we defeat the purpose of task-based concurrency (which is about never blocking)
the output would be:
Main Task
Task2
Task3
task1 would block thread forever unless I comment result1.get(), or add an empty task before task1.
The text was updated successfully, but these errors were encountered: