Register a `CancellationToken` for a running task so callers can trigger cancellation through `cancel(task_id)`. The task executor is expected to remove the entry on exit via `clear_canceller`.
(&self, task_id: &str, token: CancellationToken)
| 111 | /// trigger cancellation through `cancel(task_id)`. The task executor |
| 112 | /// is expected to remove the entry on exit via `clear_canceller`. |
| 113 | pub async fn register_canceller(&self, task_id: &str, token: CancellationToken) { |
| 114 | self.cancellers |
| 115 | .write() |
| 116 | .await |
| 117 | .insert(task_id.to_string(), token); |
| 118 | } |
| 119 | |
| 120 | pub async fn clear_canceller(&self, task_id: &str) { |
| 121 | self.cancellers.write().await.remove(task_id); |