Skip to main content

BackgroundJobManager

Struct BackgroundJobManager 

Source
pub struct BackgroundJobManager { /* private fields */ }
Expand description

Shared manager for background jobs.

Implementations§

Source§

impl BackgroundJobManager

Source

pub fn new() -> Self

Source

pub fn completed_notify(&self) -> Arc<Notify> ⓘ

Return a clone of the completed-notify handle.

Used by the TUI loop arbiter to select! on job completion. When a background job enters a terminal state (Completed, Failed, TimedOut), notify_one() is called. notify_one() (rather than notify_waiters()) stores a permit so a completion that happens while the arbiter is mid-turn (not yet polling) is not lost — the next notified() poll consumes the stored permit.

Source

pub fn insert(&mut self, job: Job) -> String

Insert a new job and return its ID.

Source

pub fn get_state(&self, id: &str) -> Option<JobState>

Get a reference to a job’s state.

Source

pub fn clear(&mut self)

Remove all jobs immediately.

Source

pub fn set_watch(&mut self, path: PathBuf, offset: u64)

Register a file for mid-run event wakes. offset is the byte offset to start reading from (typically the file size at registration time, so only bytes appended afterwards wake the agent). Replaces any prior watch.

Source

pub fn clear_watch(&mut self)

Clear any registered file watch.

Source

pub fn set_loop_control(&mut self, ctrl: LoopControl)

Set an agent-requested loop control (e.g. Stop). Replaces any prior pending control. Read and consumed by the loop arbiter between turns.

Source

pub fn take_loop_control(&mut self) -> Option<LoopControl>

Take (consume) any pending loop-control request. Returns None when nothing is pending.

Source

pub fn poll_watch(&mut self) -> Option<String>

Poll the registered watch file for new bytes past the stored offset. On success, advances the offset and returns the new content (capped at WATCH_CHUNK_BYTES per call; remaining bytes surface on the next poll). Returns None when no watch is set, the file is gone, or no new bytes are available. Handles log rotation (file shrank) by resetting to the start.

Source

pub fn take_completed(&mut self) -> Option<(String, String)>

Remove and return the first completed job, if any.

Returns Some((job_id, output_string)) where output_string includes the exit code and captured stdout/stderr. Completed jobs are removed from the tracked set.

If a terminal job remains after this removal, the completion notify is re-armed. update() uses notify_one(), which stores a single permit: when ≥2 jobs reach a terminal state before a waiter polls, the second notify_one() is a no-op, so a waiter that consumes the one permit would never wake for the remaining job. Re-arming here guarantees every completed job has a scheduled wake until it is drained (goal-379).

Trait Implementations§

Source§

impl Default for BackgroundJobManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoMaybeUndefined<T> for T

Source§

fn into_maybe_undefined(self) -> MaybeUndefined<T>

Converts this value into a three-state builder argument.
Source§

impl<T> IntoOption<T> for T

Source§

fn into_option(self) -> Option<T>

Converts this value into an optional builder argument.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more