fix at_exit and thread_at_exit (obs from Paulo Moura).
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2188 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
0dd21aab71
commit
7aab33a153
@ -48,7 +48,7 @@
|
|||||||
'$thread_zombie_self'(Id0), !,
|
'$thread_zombie_self'(Id0), !,
|
||||||
'$close_thread'(Status, Detached, Id0).
|
'$close_thread'(Status, Detached, Id0).
|
||||||
'$close_thread'(Status, Detached) :- !,
|
'$close_thread'(Status, Detached) :- !,
|
||||||
% one self will fail if it had messages
|
% zombie_self failed as it the thread was messages pending
|
||||||
'$close_thread'(Status, Detached).
|
'$close_thread'(Status, Detached).
|
||||||
|
|
||||||
|
|
||||||
@ -59,7 +59,7 @@
|
|||||||
; recorda('$thread_exit_status', [Id0|Status], _)
|
; recorda('$thread_exit_status', [Id0|Status], _)
|
||||||
).
|
).
|
||||||
% format(user_error,'closing thread ~w~n',[v([Id0|Status])]).
|
% format(user_error,'closing thread ~w~n',[v([Id0|Status])]).
|
||||||
'$close_thread'(Exception, Detached) :-
|
'$close_thread'(Exception, Detached, Id0) :-
|
||||||
'$run_at_thread_exit'(Id0),
|
'$run_at_thread_exit'(Id0),
|
||||||
( Detached == true ->
|
( Detached == true ->
|
||||||
'$erase_thread_info'(Id0)
|
'$erase_thread_info'(Id0)
|
||||||
@ -327,20 +327,15 @@ thread_exit(Term) :-
|
|||||||
|
|
||||||
'$run_at_thread_exit'(Id0) :-
|
'$run_at_thread_exit'(Id0) :-
|
||||||
recorded('$thread_at_exit',[Id0|AtExit],R), erase(R),
|
recorded('$thread_at_exit',[Id0|AtExit],R), erase(R),
|
||||||
'$thread_top_goal'(AtExit),
|
catch(once(AtExit),_,fail),
|
||||||
fail.
|
fail.
|
||||||
'$run_at_thread_exit'(Id0) :-
|
'$run_at_thread_exit'(Id0) :-
|
||||||
findall(Hook, (recorded('$thread_exit_hook',[Id0|Hook],R), erase(R)), Hooks),
|
recorded('$thread_exit_hook',[Id0|Hook],R), erase(R),
|
||||||
'$run_thread_hooks'(Hooks),
|
catch(once(Hook),_,fail),
|
||||||
fail.
|
fail.
|
||||||
'$run_at_thread_exit'(Id0) :-
|
'$run_at_thread_exit'(Id0) :-
|
||||||
message_queue_destroy(Id0).
|
message_queue_destroy(Id0).
|
||||||
|
|
||||||
'$run_thread_hooks'([]).
|
|
||||||
'$run_thread_hooks'([Hook|Hooks]) :-
|
|
||||||
'$thread_top_goal'(Hook),
|
|
||||||
'$run_thread_hooks'(Hooks).
|
|
||||||
|
|
||||||
thread_at_exit(Goal) :-
|
thread_at_exit(Goal) :-
|
||||||
'$check_callable'(Goal,thread_at_exit(Goal)),
|
'$check_callable'(Goal,thread_at_exit(Goal)),
|
||||||
'$thread_self'(Id0),
|
'$thread_self'(Id0),
|
||||||
|
Reference in New Issue
Block a user