Queries aren't thread safe. I think trail is the culprit, and binding that to a new vector when my thread starts seems to do the trick. Memory is cheap - should probably just allocate a new trail for each query. Haven't done a review of which functions would need this binding. I'm using prolog-collect. For ?- a hardcoded predicate is created and (top-level-query/0) so that would need to be addressed well.
Safety for constructing the database would be harder because of the global namespace for compiled predicates and use of the plist to store clauses. Not an issue for my use case.
Queries aren't thread safe. I think trail is the culprit, and binding that to a new vector when my thread starts seems to do the trick. Memory is cheap - should probably just allocate a new trail for each query. Haven't done a review of which functions would need this binding. I'm using prolog-collect. For ?- a hardcoded predicate is created and (top-level-query/0) so that would need to be addressed well.
Safety for constructing the database would be harder because of the global namespace for compiled predicates and use of the plist to store clauses. Not an issue for my use case.