pub struct SolverManager<S: Solvable> { /* private fields */ }Expand description
Manages async solve jobs with channel-based solution streaming.
Uses fixed-size slot array for job tracking. Solutions stream through tokio channels - the solver sends owned solutions, users receive them without cloning.
§Type Parameters
S- Solution type that implementsSolvable
§Thread Safety
SolverManager is thread-safe. Jobs can be started, queried, and terminated
from any thread.
Implementations§
Source§impl<S: Solvable> SolverManager<S>
impl<S: Solvable> SolverManager<S>
Sourcepub fn solve(
&'static self,
solution: S,
) -> (usize, UnboundedReceiver<(S, S::Score)>)
pub fn solve( &'static self, solution: S, ) -> (usize, UnboundedReceiver<(S, S::Score)>)
Starts solving and returns a receiver for streaming solutions.
The solver runs asynchronously via rayon. Solutions stream through the returned receiver as they’re found. Each solution is owned - no cloning occurs.
§Arguments
solution- The starting solution (ownership transferred)
§Returns
A tuple of (job_id, receiver). The receiver yields (solution, score)
pairs as new best solutions are found.
§Panics
Panics if no free slots are available.
Sourcepub fn get_status(&self, job_id: usize) -> SolverStatus
pub fn get_status(&self, job_id: usize) -> SolverStatus
Gets the solver status for a job.
Sourcepub fn terminate_early(&self, job_id: usize) -> bool
pub fn terminate_early(&self, job_id: usize) -> bool
Requests early termination of a job.
Returns true if the job was found and is currently solving.
Sourcepub fn free_slot(&self, job_id: usize)
pub fn free_slot(&self, job_id: usize)
Frees a job slot after solving completes.
Call this after the receiver is drained to allow reuse of the slot.
Sourcepub fn active_job_count(&self) -> usize
pub fn active_job_count(&self) -> usize
Returns the number of active (solving) jobs.
Trait Implementations§
Auto Trait Implementations§
impl<S> !Freeze for SolverManager<S>
impl<S> RefUnwindSafe for SolverManager<S>
impl<S> Send for SolverManager<S>
impl<S> Sync for SolverManager<S>
impl<S> Unpin for SolverManager<S>
impl<S> UnwindSafe for SolverManager<S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more