Closed mattwigway closed 1 year ago
Alternate, probably better solution: create a Julia callback that is called from C and just uses the values on the stack.
The Julia documentation says (emphasis mine):
Some C libraries execute their callbacks from a different thread, and since Julia isn't thread-safe you'll need to take some extra precautions. In particular, you'll need to set up a two-layered system: the C callback should only schedule (via Julia's event loop) the execution of your "real" callback.
It's likely we'll be running calls to OSRM in different Julia threads. Will that be an issue?
This thread seems to indicate that as long as the callback is in any Julia thread, it will be fine.
Before returning a route result from the C++ shim, we wrap it in a new object to force heap allocation. Does this do a deep copy, or is it possible there are some references to stack memory still in there?