quek / paiprolog

forked Christophe Rhodes's PAIProlog that an update of Peter Norvig's "Prolog in Common Lisp".
Other
18 stars 6 forks source link

Thread safety #18

Open alanruttenberg opened 6 years ago

alanruttenberg commented 6 years ago

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.

quek commented 6 years ago

I have not used piaprolog recently. Would you be a collaborators?