◆ 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:154
std::unordered_map< Id, Promise< void > > tasks_
Definition combinators.cc:155
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:158
◆ 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:159
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:156
◆ wrap()
| Promise< void > uvco::anonymous_namespace{combinators.cc}::TaskSetImpl::wrap |
( |
Id | taskId, |
|
|
Promise< void > | task ) |
|
inlineprivate |
109 {
110
111
112 try {
113 Promise<void> shortlivedTask{std::move(task)};
114 co_await shortlivedTask;
115 } catch (const std::exception &e) {
118 } else {
119 fmt::print(stderr,
120 "TaskSet task {} failed with exception: {} (setOnError() to "
121 "suppress this message)\n",
122 taskId, e.what());
123 }
124 } catch (...) {
127 } else {
128 fmt::print(stderr,
129 "TaskSet task {} failed with unknown exception "
130 "(setOnError() to suppress this message)\n",
131 taskId);
132 }
133 }
134
135
136
137
140 }
141
142
146 }
147
148
149
150
152 }
◆ 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: