Skip to main content

ThreadedSolver

Struct ThreadedSolver 

Source
pub struct ThreadedSolver<S> { /* private fields */ }
Expand description

Runs each question on its own thread and waits at most timeout: an answer that is late is abandoned and reported as MbaAnswer::Exhausted (never cached, so a later call may try again). While max_abandoned abandoned questions are still running, new ones are refused as exhausted, which bounds the threads left behind. The only threads are the ones this instance starts; nothing is global.

A deadline makes answers depend on timing; the engine treats an exhausted answer as not final, so a memoized result never depends on it. A panic inside the solver is answered as unsupported. The cap is checked before a question starts, so concurrent callers may briefly exceed it by their number.

Implementations§

Source§

impl<S: MbaSolver + 'static> ThreadedSolver<S>

Source

pub fn new(inner: S, timeout: Duration, max_abandoned: usize) -> Self

Wraps inner with a deadline.

Source

pub fn abandoned(&self) -> usize

Questions abandoned and still running.

Trait Implementations§

Source§

impl<S> Debug for ThreadedSolver<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: MbaSolver + 'static> MbaSolver for ThreadedSolver<S>

Source§

fn solve_counted(&self, p: &MbaExpr, budget: &MbaBudget) -> (MbaAnswer, u64)

The inner solver’s steps; a question abandoned at the deadline is charged its limit (it may still be running), one refused or not started nothing.

Source§

fn id(&self) -> &str

A stable name, including anything that changes answers (it keys the caches).
Source§

fn polynomial_fragments(&self) -> bool

Whether Phase::Mba should also ask about polynomials: fragments without bitwise operators in which two non-constants are multiplied, and fragments rooted at a constant left shift. By default only mixed fragments (arithmetic and bitwise operators) rooted at + − · neg & | ^ ~ are asked about.
Source§

fn solve(&self, p: &MbaExpr, budget: &MbaBudget) -> MbaAnswer

Simplifies p.

Auto Trait Implementations§

§

impl<S> Forget for ThreadedSolver<S>

§

impl<S> Freeze for ThreadedSolver<S>
where Arc<S>: Freeze,

§

impl<S> Move for ThreadedSolver<S>

§

impl<S> RefUnwindSafe for ThreadedSolver<S>
where Arc<S>: RefUnwindSafe,

§

impl<S> Send for ThreadedSolver<S>
where Arc<S>: Send,

§

impl<S> Sync for ThreadedSolver<S>
where Arc<S>: Sync,

§

impl<S> Unpin for ThreadedSolver<S>
where Arc<S>: Unpin,

§

impl<S> UnsafeUnpin for ThreadedSolver<S>
where Arc<S>: UnsafeUnpin,

§

impl<S> UnwindSafe for ThreadedSolver<S>
where Arc<S>: UnwindSafe,

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<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, 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.