|
uvco 0.1
|
#include <combinators.h>

Public Types | |
| using | Id = size_t |
| using | ErrorCallback = std::function<void(Id, std::exception_ptr)> |
Public Member Functions | |
| TaskSet ()=default | |
| TaskSet (const TaskSet &)=delete | |
| TaskSet (TaskSet &&) noexcept=default | |
| TaskSet & | operator= (const TaskSet &)=delete |
| TaskSet & | operator= (TaskSet &&) noexcept=default |
| virtual | ~TaskSet ()=default |
| virtual Id | add (Promise< void > task)=0 |
| virtual bool | empty ()=0 |
| Check if there are any active tasks on the TaskSet. | |
| virtual Promise< void > | onEmpty ()=0 |
| virtual void | setOnError (ErrorCallback callback)=0 |
Static Public Member Functions | |
| static std::unique_ptr< TaskSet > | create () |
TaskSet handles the common case of maintaining a set of coroutines running in the background which should not be cancelled, but should be cleaned up after finishing.
| using uvco::TaskSet::ErrorCallback = std::function<void(Id, std::exception_ptr)> |
| using uvco::TaskSet::Id = size_t |
|
default |
|
delete |
|
defaultnoexcept |
|
virtualdefault |
Add a task to the TaskSet. It will be run to completion. If an exception is thrown, it is printed to stderr, or an ErrorCallback will be called if set before using setOnError().
Implemented in uvco::anonymous_namespace{combinators.cc}::TaskSetImpl.
|
static |
Create a new TaskSet, which can be used to hold a set of background tasks, cleaning up resources of finished tasks automatically.
The implementation is hidden in the .cc file to hide complexity from units including this header.
|
pure virtual |
Check if there are any active tasks on the TaskSet.
Implemented in uvco::anonymous_namespace{combinators.cc}::TaskSetImpl.
|
pure virtual |
Return a Promise which will be fulfilled when no tasks are left on the TaskSet. Multiple calls to this will return Promise instances which will become ready simultaneously; this means that depending on the scheduling order, by the time this Promise resolves, the TaskSet instance may not be empty anymore.
Implemented in uvco::anonymous_namespace{combinators.cc}::TaskSetImpl.
|
pure virtual |
Register a callback which handles errors thrown by tasks. By default, errors are logged to stderr. The callback is called when a task finishes by throwing an exception.
Implemented in uvco::anonymous_namespace{combinators.cc}::TaskSetImpl.