| 203 | } |
| 204 | |
| 205 | bool RunnerBase::try_cancel(SkrAsyncServicePriority priority, IORequestId rq) SKR_NOEXCEPT |
| 206 | { |
| 207 | if (auto pComp = io_component<IOStatusComponent>(rq.get())) |
| 208 | { |
| 209 | const auto status = pComp->getStatus(); |
| 210 | if (status == SKR_IO_STAGE_CANCELLED) return true; |
| 211 | if (status == SKR_IO_STAGE_LOADING) return false; |
| 212 | |
| 213 | if (bool cancel_requested = pComp->getCancelRequested()) |
| 214 | { |
| 215 | if (pComp->getFinishStep() == SKR_ASYNC_IO_FINISH_STEP_NONE) |
| 216 | { |
| 217 | if (pComp->is_async_cancel()) |
| 218 | { |
| 219 | auto cancel = [this, priority, rq = rq.get()] { return cancel_(rq, priority); }; |
| 220 | finish_futures.emplace_back(skr::FutureLauncher<bool>(job_queue).async(cancel), rq); |
| 221 | } |
| 222 | else |
| 223 | { |
| 224 | cancel_(rq.get(), priority); |
| 225 | } |
| 226 | } |
| 227 | // remove from batch |
| 228 | if (auto batch = static_cast<IOBatchBase*>(pComp->getOwnerBatch())) |
| 229 | batch->removeCancelledRequest(rq); |
| 230 | else |
| 231 | SKR_UNREACHABLE_CODE(); |
| 232 | return true; |
| 233 | } |
| 234 | } |
| 235 | return false; |
| 236 | } |
| 237 | |
| 238 | void RunnerBase::dispatch_complete_(SkrAsyncServicePriority priority, IORequestId rq) SKR_NOEXCEPT |
| 239 | { |
no test coverage detected