Skip to content

Commit 9dae425

Browse files
committed
Improved callback code
1 parent 9bc4831 commit 9dae425

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

ext/or-tools/constraint.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,12 @@ void init_constraint(Rice::Module& m) {
409409

410410
m.Add(NewFeasibleSolutionObserver(
411411
[&callback](const CpSolverResponse& r) {
412-
// TODO find a better way to do this
413-
callback.call("response=", r);
414-
callback.call("on_solution_callback");
412+
// ensure Ruby thread
413+
if (ruby_native_thread_p()) {
414+
// TODO find a better way to do this
415+
callback.iv_set("@response", r);
416+
callback.call("on_solution_callback");
417+
}
415418
})
416419
);
417420
}

0 commit comments

Comments
 (0)