Updated the implementation of the thread_detach/1 predicate to help ensure that threads already terminated at the time of the call are destroyed instead of becoming zombie threads.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2173 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
8a1cfeb770
commit
8a318a5e83
@ -147,14 +147,14 @@ thread_create(Goal, OutId, Options) :-
|
|||||||
|
|
||||||
'$thread_option'(Option, _, _, _, _, _, _, G0) :- var(Option), !,
|
'$thread_option'(Option, _, _, _, _, _, _, G0) :- var(Option), !,
|
||||||
'$do_error'(instantiation_error,G0).
|
'$do_error'(instantiation_error,G0).
|
||||||
|
'$thread_option'(alias(Alias), Alias, _, _, _, _, _, G0) :- !,
|
||||||
|
( \+ atom(Alias) -> '$do_error'(type_error(atom,Alias),G0) ; true ).
|
||||||
'$thread_option'(stack(Stack), _, Stack, _, _, _, _, G0) :- !,
|
'$thread_option'(stack(Stack), _, Stack, _, _, _, _, G0) :- !,
|
||||||
( \+ integer(Stack) -> '$do_error'(type_error(integer,Stack),G0) ; true ).
|
( \+ integer(Stack) -> '$do_error'(type_error(integer,Stack),G0) ; true ).
|
||||||
'$thread_option'(trail(Trail), _, _, Trail, _, _, _, G0) :- !,
|
'$thread_option'(trail(Trail), _, _, Trail, _, _, _, G0) :- !,
|
||||||
( \+ integer(Trail) -> '$do_error'(type_error(integer,Trail),G0) ; true ).
|
( \+ integer(Trail) -> '$do_error'(type_error(integer,Trail),G0) ; true ).
|
||||||
'$thread_option'(system(System), _, _, _, System, _, _, G0) :- !,
|
'$thread_option'(system(System), _, _, _, System, _, _, G0) :- !,
|
||||||
( \+ integer(System) -> '$do_error'(type_error(integer,System),G0) ; true ).
|
( \+ integer(System) -> '$do_error'(type_error(integer,System),G0) ; true ).
|
||||||
'$thread_option'(alias(Alias), Alias, _, _, _, _, _, G0) :- !,
|
|
||||||
( \+ atom(Alias) -> '$do_error'(type_error(atom,Alias),G0) ; true ).
|
|
||||||
'$thread_option'(detached(Detached), _, _, _, _, Detached, _, G0) :- !,
|
'$thread_option'(detached(Detached), _, _, _, _, Detached, _, G0) :- !,
|
||||||
( Detached \== true, Detached \== false -> '$do_error'(domain_error(thread_option,Detached+[true,false]),G0) ; true ).
|
( Detached \== true, Detached \== false -> '$do_error'(domain_error(thread_option,Detached+[true,false]),G0) ; true ).
|
||||||
'$thread_option'(at_exit(AtExit), _, _, _, _, _, AtExit, G0) :- !,
|
'$thread_option'(at_exit(AtExit), _, _, _, _, _, AtExit, G0) :- !,
|
||||||
@ -314,6 +314,11 @@ thread_detach(Id) :-
|
|||||||
fail
|
fail
|
||||||
;
|
;
|
||||||
'$detach_thread'(Id0)
|
'$detach_thread'(Id0)
|
||||||
|
),
|
||||||
|
( recorded('$thread_exit_status', [Id0|_], _) ->
|
||||||
|
'$erase_thread_info'(Id0),
|
||||||
|
'$thread_destroy'(Id0)
|
||||||
|
; true
|
||||||
).
|
).
|
||||||
|
|
||||||
thread_exit(Term) :-
|
thread_exit(Term) :-
|
||||||
@ -324,7 +329,6 @@ 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),
|
||||||
writeq(at_exit-AtExit), nl,
|
|
||||||
'$thread_top_goal'(AtExit),
|
'$thread_top_goal'(AtExit),
|
||||||
fail.
|
fail.
|
||||||
'$run_at_thread_exit'(Id0) :-
|
'$run_at_thread_exit'(Id0) :-
|
||||||
|
Reference in New Issue
Block a user