◆ TaskSetImpl() [1/3]
| uvco::anonymous_namespace{combinators.cc}::TaskSetImpl::TaskSetImpl |
( |
| ) |
|
|
default |
◆ TaskSetImpl() [2/3]
| uvco::anonymous_namespace{combinators.cc}::TaskSetImpl::TaskSetImpl |
( |
const TaskSetImpl & | | ) |
|
|
delete |
◆ TaskSetImpl() [3/3]
| uvco::anonymous_namespace{combinators.cc}::TaskSetImpl::TaskSetImpl |
( |
TaskSetImpl && | | ) |
|
|
delete |
◆ ~TaskSetImpl()
| uvco::anonymous_namespace{combinators.cc}::TaskSetImpl::~TaskSetImpl |
( |
| ) |
|
|
overridedefault |
◆ add()
| Id uvco::anonymous_namespace{combinators.cc}::TaskSetImpl::add |
( |
Promise< void > | task | ) |
|
|
inlineoverrideprivatevirtual |
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().
Implements uvco::TaskSet.
90 {
92 tasks_.insert({taskId,
wrap(taskId, std::move(task))});
93 return taskId;
94 }
size_t Id
Definition combinators.h:145
Id counter_
Definition combinators.cc:153
std::unordered_map< Id, Promise< void > > tasks_
Definition combinators.cc:154
Promise< void > wrap(Id taskId, Promise< void > task)
Definition combinators.cc:109
◆ empty()
| bool uvco::anonymous_namespace{combinators.cc}::TaskSetImpl::empty |
( |
| ) |
|
|
inlineoverrideprivatevirtual |
Check if there are any active tasks on the TaskSet.
Implements uvco::TaskSet.
std::deque< Id > doneTasks_
Definition combinators.cc:157
◆ onEmpty()
| Promise< void > uvco::anonymous_namespace{combinators.cc}::TaskSetImpl::onEmpty |
( |
| ) |
|
|
inlineoverrideprivatevirtual |
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.
Implements uvco::TaskSet.
98 {
100 co_return;
101 }
103 }
WaitPoint onEmpty_
Definition combinators.cc:158
bool empty() override
Check if there are any active tasks on the TaskSet.
Definition combinators.cc:96
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ setOnError()
| void uvco::anonymous_namespace{combinators.cc}::TaskSetImpl::setOnError |
( |
ErrorCallback | callback | ) |
|
|
inlineoverrideprivatevirtual |
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.
Implements uvco::TaskSet.
105 {
107 }
ErrorCallback errorCallback_
Definition combinators.cc:155
◆ wrap()
| Promise< void > uvco::anonymous_namespace{combinators.cc}::TaskSetImpl::wrap |
( |
Id | taskId, |
|
|
Promise< void > | task ) |
|
inlineprivate |
109 {
110
111
112 try {
113 co_await task;
114 } catch (const std::exception &e) {
117 } else {
118 fmt::print(stderr,
119 "TaskSet task {} failed with exception: {} (setOnError() to "
120 "suppress this message)\n",
121 taskId, e.what());
122 }
123 } catch (...) {
126 } else {
127 fmt::print(stderr,
128 "TaskSet task {} failed with unknown exception "
129 "(setOnError() to suppress this message)\n",
130 taskId);
131 }
132 }
133
134
135
136
139 }
140
141
145 }
146
147
148
149
151 }
◆ counter_
| Id uvco::anonymous_namespace{combinators.cc}::TaskSetImpl::counter_ = 0 |
|
private |
◆ doneTasks_
| std::deque<Id> uvco::anonymous_namespace{combinators.cc}::TaskSetImpl::doneTasks_ {} |
|
private |
◆ errorCallback_
| ErrorCallback uvco::anonymous_namespace{combinators.cc}::TaskSetImpl::errorCallback_ |
|
private |
◆ onEmpty_
| WaitPoint uvco::anonymous_namespace{combinators.cc}::TaskSetImpl::onEmpty_ {} |
|
private |
◆ tasks_
| std::unordered_map<Id, Promise<void> > uvco::anonymous_namespace{combinators.cc}::TaskSetImpl::tasks_ {} |
|
private |
The documentation for this class was generated from the following file: