MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / register_task

Method register_task

nodedb/src/control/shutdown/bus.rs:220–246  ·  view source on GitHub ↗

Register a task for the given drain phase. Returns a `DrainGuard` the task must hold until its cleanup is complete. `abort_handle`: if `Some`, the task will be aborted if it misses the budget. Pass `None` for blocking threads.

(
        &self,
        drain_at: ShutdownPhase,
        name: &'static str,
        abort_handle: Option<tokio::task::AbortHandle>,
    )

Source from the content-addressed store, hash-verified

218 /// `abort_handle`: if `Some`, the task will be aborted if it misses
219 /// the budget. Pass `None` for blocking threads.
220 pub fn register_task(
221 &self,
222 drain_at: ShutdownPhase,
223 name: &'static str,
224 abort_handle: Option<tokio::task::AbortHandle>,
225 ) -> DrainGuard {
226 let mut guard = lock_bus(&self.state);
227 let id = guard.alloc_id();
228 guard.tasks.insert(
229 id,
230 TaskEntry {
231 name,
232 phase: drain_at,
233 drained: false,
234 abort_handle,
235 },
236 );
237 let phase_rx = self.phase_tx.subscribe();
238 DrainGuard {
239 task_id: id,
240 phase: drain_at,
241 state: Arc::clone(&self.state),
242 phase_rx,
243 reported: false,
244 name,
245 }
246 }
247
248 /// Initiate graceful shutdown. Idempotent — second call is a no-op.
249 ///

Callers 10

mainFunction · 0.80
spawn_drainableFunction · 0.80
runMethod · 0.80
runMethod · 0.80
runMethod · 0.80
runMethod · 0.80
run_with_listenerFunction · 0.80
runFunction · 0.80

Calls 4

lock_busFunction · 0.85
alloc_idMethod · 0.80
insertMethod · 0.45
subscribeMethod · 0.45

Tested by

no test coverage detected