mamba-org / resolvo

Fast package resolver written in Rust (CDCL based SAT solving)
BSD 3-Clause "New" or "Revised" License
160 stars 13 forks source link

feat: allow cancelling the solving process #20

Closed aochagavia closed 9 months ago

aochagavia commented 9 months ago

Introduces a should_cancel_with_value method in DependencyProvider, that returns an Option<Box<dyn Any>>. This method is called at the beginning of each unit propagation round and before potentially blocking operations (like [Self::get_dependencies] and [Self::get_candidates]).

If should_cancel_with_value returns Some(...), propagation is interrupted and the solver returns Err(UnsolvableOrCancelled::Cancelled(...)), bubbling up the value to the library user (this way you can handle any additional details surrounding the cancellation outside of the solver).

Closes #8.

Remarks