Commit b39b55e8 by Alan Mishchenko

Adding a callback feature to Satoko.

parent cf427690
...@@ -639,7 +639,7 @@ char solver_search(solver_t *s) ...@@ -639,7 +639,7 @@ char solver_search(solver_t *s)
/* No conflict */ /* No conflict */
unsigned next_lit; unsigned next_lit;
if (solver_rst(s) || solver_check_limits(s) == 0) { if (solver_rst(s) || solver_check_limits(s) == 0 || solver_stop(s)) {
b_queue_clean(s->bq_lbd); b_queue_clean(s->bq_lbd);
solver_cancel_until(s, 0); solver_cancel_until(s, 0);
return SATOKO_UNDEC; return SATOKO_UNDEC;
......
...@@ -103,6 +103,9 @@ struct solver_t_ { ...@@ -103,6 +103,9 @@ struct solver_t_ {
/* Temporary data used for solving cones */ /* Temporary data used for solving cones */
vec_char_t *marks; vec_char_t *marks;
/* Callback to stop the solver */
int * pstop;
struct satoko_stats stats; struct satoko_stats stats;
struct satoko_opts opts; struct satoko_opts opts;
}; };
...@@ -223,6 +226,14 @@ static inline int solver_has_marks(solver_t *s) ...@@ -223,6 +226,14 @@ static inline int solver_has_marks(solver_t *s)
{ {
return (int)(s->marks != NULL); return (int)(s->marks != NULL);
} }
static inline int solver_stop(solver_t *s)
{
return s->pstop && *s->pstop;
}
static inline void solver_set_stop(solver_t *s, int * pstop)
{
s->pstop = pstop;
}
//===------------------------------------------------------------------------=== //===------------------------------------------------------------------------===
// Inline clause functions // Inline clause functions
......
...@@ -303,7 +303,7 @@ int satoko_solve(solver_t *s) ...@@ -303,7 +303,7 @@ int satoko_solve(solver_t *s)
while (status == SATOKO_UNDEC) { while (status == SATOKO_UNDEC) {
status = solver_search(s); status = solver_search(s);
if (solver_check_limits(s) == 0) if (solver_check_limits(s) == 0 || solver_stop(s))
break; break;
} }
if (s->opts.verbose) if (s->opts.verbose)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment