Fix termination conditions for failed and detached threads.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1654 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2006-05-25 16:57:21 +00:00
parent f5b9000018
commit 1d445a731d
2 changed files with 14 additions and 7 deletions

View File

@ -143,14 +143,13 @@ thread_run(void *widp)
{
Term tgoal;
Term tgs[2];
int out;
int myworker_id = *((int *)widp);
start_thread(myworker_id);
tgs[0] = Yap_FetchTermFromDB(ThreadHandle[worker_id].tgoal);
tgs[1] = ThreadHandle[worker_id].tdetach;
tgoal = Yap_MkApplTerm(FunctorThreadRun, 2, tgs);
out = Yap_RunTopGoal(tgoal);
Yap_RunTopGoal(tgoal);
thread_die(worker_id, FALSE);
return NULL;
}

View File

@ -33,21 +33,29 @@
'$thread_self'(Id),
(Detached == true -> '$detach_thread'(Id) ; true),
'$current_module'(Module),
'$system_catch'((G,'$close_thread'),Module,Exception,'$thread_exception'(Exception)).
'$system_catch'((G,'$close_thread'(Detached,true) ; '$close_thread'(Detached,false)),Module,Exception,'$thread_exception'(Exception,Detached)).
'$top_thread_goal'(_) :-
'$thread_self'(Id0),
recorda('$thread_exit_status', [Id0|false], _),
'$run_at_thread_exit'(Id0).
'$close_thread' :-
'$close_thread'(Detached, Status) :-
'$thread_self'(Id0),
recorda('$thread_exit_status', [Id0|true], _),
(Detached == true ->
true
;
recorda('$thread_exit_status', [Id0|Status], _)
),
'$run_at_thread_exit'(Id0).
'$thread_exception'(Exception) :-
'$thread_exception'(Exception,Detached) :-
'$thread_self'(Id0),
recorda('$thread_exit_status', [Id0|exception(Exception)], _),
(Detached == true ->
true
;
recorda('$thread_exit_status', [Id0|exception(Exception)], _)
),
'$run_at_thread_exit'(Id0).
thread_create(Goal, Id) :-