template <typename I>
void ImageWatcher<I>::schedule_async_progress(const AsyncRequestId &request,
uint64_t offset, uint64_t total) {
- auto ctx = new LambdaContext(
- boost::bind(&ImageWatcher<I>::notify_async_progress, this, request, offset,
- total));
+ auto ctx = new LambdaContext([this, request, offset, total](int r) {
+ if (r != -ECANCELED) {
+ notify_async_progress(request, offset, total);
+ }
+ });
m_task_finisher->queue(Task(TASK_CODE_ASYNC_PROGRESS, request), ctx);
}
void ImageWatcher<I>::schedule_async_complete(const AsyncRequestId &request,
int r) {
m_async_op_tracker.start_op();
- auto ctx = new LambdaContext(
- boost::bind(&ImageWatcher<I>::notify_async_complete, this, request, r));
+ auto ctx = new LambdaContext([this, request, ret_val=r](int r) {
+ if (r != -ECANCELED) {
+ notify_async_complete(request, ret_val);
+ }
+ });
m_task_finisher->queue(ctx);
}
template <typename I>
void ImageWatcher<I>::schedule_cancel_async_requests() {
- auto ctx = new LambdaContext(
- boost::bind(&ImageWatcher<I>::cancel_async_requests, this));
+ auto ctx = new LambdaContext([this](int r) {
+ if (r != -ECANCELED) {
+ cancel_async_requests();
+ }
+ });
m_task_finisher->queue(TASK_CODE_CANCEL_ASYNC_REQUESTS, ctx);
}
if (it != m_task_contexts.end()) {
if (it->second.second != NULL &&
m_safe_timer->cancel_event(it->second.second)) {
- delete it->second.first;
+ it->second.first->complete(-ECANCELED);
} else {
// task already scheduled on the finisher
- delete ctx;
+ ctx->complete(-ECANCELED);
return false;
}
}