Added error checking code to the predicates thread_exit/1 and thread_signal/2.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1763 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
pmoura 2007-01-01 17:20:56 +00:00
parent bf002885d7
commit 2896253b4c

View File

@ -272,6 +272,9 @@ thread_detach(Id) :-
thread_detach(Id) :-
'$do_error'(existence_error(thread, Id),thread_detach(Id)).
thread_exit(Term) :-
var(Term), !,
'$do_error'(instantiation_error, thread_exit(Term)).
thread_exit(Term) :-
'$thread_self'(Id0),
'$run_at_thread_exit'(Id0),
@ -595,16 +598,22 @@ thread_sleep(Time) :-
thread_signal(Thread, Goal) :-
var(Thread), !,
'$do_error'(instantiation_error,thread_signal(Thread, Goal)).
thread_signal(Thread, Goal) :-
\+ integer(Thread), \+ atom(Thread), !,
'$do_error'(domain_error,thread_or_alias,thread_signal(Thread, Goal)).
thread_signal(Thread, Goal) :-
'$check_callable'(Goal,thread_signal(Thread,Goal)).
thread_signal(Thread, Goal) :-
recorded('$thread_alias',[Id|Thread],_), !,
atom(Thread),
recorded('$thread_alias',[Id|Thread],_),
'$valid_thread'(Id), !,
'$thread_signal'(Id, Goal).
thread_signal(Thread, Goal) :-
integer(Thread), !,
integer(Thread),
'$valid_thread'(Thread), !,
'$thread_signal'(Thread, Goal).
thread_signal(Thread, Goal) :-
'$do_error'(type_error(integer,Thread),thread_signal(Thread, Goal)).
'$do_error'(existence_error(thread, Thread),thread_signal(Thread, Goal)).
'$thread_signal'(Thread, Goal) :-
( recorded('$thread_signal',[Thread|_],R), erase(R), fail ; true ),