From 5d6ddc8026a8ad21fe2666801e5cb8cfaeac1221 Mon Sep 17 00:00:00 2001 From: pmoura Date: Thu, 3 Apr 2008 01:22:47 +0000 Subject: [PATCH] Fixed two bugs when closing a thread: (1) register thread exit status before running the exit hooks; (2) incorrect register of exception exit status. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2197 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- pl/threads.yap | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pl/threads.yap b/pl/threads.yap index efd92b72f..073a8aa9c 100644 --- a/pl/threads.yap +++ b/pl/threads.yap @@ -53,22 +53,21 @@ '$close_thread'('$thread_finished'(Status), Detached, Id0) :- !, + recorda('$thread_exit_status', [Id0|Status], _), '$run_at_thread_exit'(Id0), ( Detached == true -> '$erase_thread_info'(Id0) - ; recorda('$thread_exit_status', [Id0|Status], _) + ; true ). % format(user_error,'closing thread ~w~n',[v([Id0|Status])]). '$close_thread'(Exception, Detached, Id0) :- + ( recorded('$thread_exit_status',[Id0|_],R), erase(R), fail + ; recorda('$thread_exit_status', [Id0|exception(error(Exception,_))]) + ), '$run_at_thread_exit'(Id0), ( Detached == true -> '$erase_thread_info'(Id0) - ; - ( - recorded('$thread_exit_status',[Id|_],R), erase(R), fail - ; - recorda('$thread_exit_status', [Id|exception(error(resource_error(memory),thread_create(Goal,Id)))]) - ) + ; true ). thread_create(Goal) :-