aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/coord
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-05-23 16:48:58 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-05-23 16:54:59 +0200
commitc6a77f30f64be73a5e55e06336975f2ecfbb2324 (patch)
tree3c243fbee268b824f18c5dc4d5bff9a9413b9407 /src/solvers/coord
parent62d87e063318cc4c842b1b2d8c184f48aeaf6659 (diff)
downloadnissy-core-c6a77f30f64be73a5e55e06336975f2ecfbb2324.tar.gz
nissy-core-c6a77f30f64be73a5e55e06336975f2ecfbb2324.zip
Do all loggin in main thread
Before this committ, the solver (via the generic solution-appender routines in src/solve/solutions.h) and the H48 data generator did some logging in the worker threads, without using any locks. This was not nice, but in practice it did not cause any problem, because the log messages were rare. However, this turned out to be a problem when building to WASM, because web workers do not have access to the main JS memory, and therefore they cannot call functions from the main JS. This includes not only the callback functions for logging, but also those for polling the status of the solver (run / pause / stop). This commit fixes this at the cost or being somewhat inelegant: the solutions are not logged as they are found, but only every 500ms.
Diffstat (limited to 'src/solvers/coord')
-rw-r--r--src/solvers/coord/solve.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/solvers/coord/solve.h b/src/solvers/coord/solve.h
index 659040c..018aa90 100644
--- a/src/solvers/coord/solve.h
+++ b/src/solvers/coord/solve.h
@@ -123,8 +123,7 @@ solve_coord_dfs(dfsarg_solve_coord_t arg[static 1])
123 if (!coord_solution_admissible(arg)) 123 if (!coord_solution_admissible(arg))
124 return 0; 124 return 0;
125 return appendsolution(arg->solution_moves, 125 return appendsolution(arg->solution_moves,
126 arg->solution_settings, arg->solution_list, true, 126 arg->solution_settings, arg->solution_list);
127 arg->coord->name);
128 } 127 }
129 128
130 if (solve_coord_dfs_stop(arg)) 129 if (solve_coord_dfs_stop(arg))
@@ -326,7 +325,7 @@ solve_coord(
326 325
327 if (coord->coord(c, coord_data) == 0) { 326 if (coord->coord(c, coord_data) == 0) {
328 if (minmoves == 0 && !appendsolution(&solution_moves, 327 if (minmoves == 0 && !appendsolution(&solution_moves,
329 &solution_settings, &solution_list, true, coord->name)) 328 &solution_settings, &solution_list))
330 goto solve_coord_error_buffer; 329 goto solve_coord_error_buffer;
331 goto solve_coord_done; 330 goto solve_coord_done;
332 } 331 }

Generated with cgit - Back to sebastiano.tronto.net