From 57ca6f6406ebe4e298aee890a6d67771de02e654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Thu, 17 Jun 2010 00:26:41 +0100 Subject: [PATCH] fix with_mutex in uni-threaded case. avoid dynamics for stable data. --- pl/threads.yap | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pl/threads.yap b/pl/threads.yap index b50fbf9df..b0f45a05e 100644 --- a/pl/threads.yap +++ b/pl/threads.yap @@ -39,7 +39,6 @@ volatile(P) :- '$do_volatile'(P,M) :- dynamic(M:P). - :- initialization('$init_thread0'). '$init_thread0' :- @@ -51,7 +50,7 @@ volatile(P) :- recorda('$thread_defaults', [0, 0, 0, false, true], _), '$create_thread_mq'(0), '$new_mutex'(Id), - assert('$with_mutex_mutex'(Id)). + assert_static(prolog:'$with_mutex_mutex'(Id)). '$top_thread_goal'(G, Detached) :- '$thread_self'(Id), @@ -503,6 +502,9 @@ mutex_unlock_all :- '$unlock_mutex'(Id), '$mutex_unlock_all'(Id). +with_mutex(M, G) :- + '$no_threads', !, + call(G). with_mutex(M, G) :- var(M), !, '$do_error'(instantiation_error,with_mutex(M, G)).