Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ctl-C catching in fzn-huub #37

Merged
merged 4 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,7 @@ unseparated_literal_suffix = "warn"
unnecessary_safety_doc = "warn"
wildcard_dependencies = "warn"
wrong_self_convention = "warn"

[profile.release-with-debug]
inherits = "release"
debug = true
10 changes: 5 additions & 5 deletions crates/fzn-huub/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,19 @@ fn main() -> Result<()> {
let interrupted = Arc::new(AtomicBool::new(false));
match (interrupt_handling, deadline) {
(true, Some(deadline)) => {
let int_bool = Arc::clone(&interrupted);
let interrupted = Arc::clone(&interrupted);
slv.set_terminate_callback(Some(move || {
if int_bool.load(Ordering::SeqCst) || Instant::now() >= deadline {
if interrupted.load(Ordering::SeqCst) || Instant::now() >= deadline {
SlvTermSignal::Terminate
} else {
SlvTermSignal::Continue
}
}));
}
(true, None) => {
let int_bool = Arc::clone(&interrupted);
let interrupted = Arc::clone(&interrupted);
slv.set_terminate_callback(Some(move || {
if int_bool.load(Ordering::SeqCst) {
if interrupted.load(Ordering::SeqCst) {
SlvTermSignal::Terminate
} else {
SlvTermSignal::Continue
Expand Down Expand Up @@ -214,7 +214,7 @@ fn main() -> Result<()> {
} else {
// Set up Ctrl-C handler (to allow printing last solution)
if let Err(err) = ctrlc::set_handler(move || {
interrupted.store(false, Ordering::SeqCst);
interrupted.store(true, Ordering::SeqCst);
}) {
warn!("unable to set Ctrl-C handler: {}", err);
}
Expand Down
4 changes: 2 additions & 2 deletions crates/huub/src/solver/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use pindakaas::{
solver::{Propagator as IpasirPropagator, SolvingActions},
Lit as RawLit, Var as RawVar,
};
use tracing::{debug, error, trace};
use tracing::{debug, trace};

use self::{
bool_to_int::BoolToIntMap,
Expand Down Expand Up @@ -135,7 +135,7 @@ impl IpasirPropagator for Engine {
for l in &clause {
let val = self.state.sat_trail.get(!l);
if !val.unwrap_or(false) {
error!(lit_prop = i32::from(*lit), lit_reason= i32::from(!l), reason_val = ?val, "invalid reason");
tracing::error!(lit_prop = i32::from(*lit), lit_reason= i32::from(!l), reason_val = ?val, "invalid reason");
}
debug_assert!(
val.unwrap_or(false),
Expand Down
Loading