From 0711088664cb44ed9aae7afe8abb71ff366168c7 Mon Sep 17 00:00:00 2001 From: pmoura Date: Sun, 31 Dec 2006 22:23:24 +0000 Subject: [PATCH] Added error checking code to the predicate thread_detach/1. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1761 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- pl/threads.yap | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pl/threads.yap b/pl/threads.yap index cc4c460ca..015a228d5 100644 --- a/pl/threads.yap +++ b/pl/threads.yap @@ -237,8 +237,23 @@ thread_join(Id, Status) :- '$erase_thread_aliases'(_). thread_detach(Id) :- - '$check_thread_alias'(Id0,Id), + var(Id), !, + '$do_error'(instantiation_error,thread_detach(Id)). +thread_detach(Id) :- + \+ atom(Id), + \+ integer(Id), + '$do_error'(type_error(thread_or_alias, Id),thread_detach(Id)). +thread_detach(Id) :- + atom(Id), + recorded('$thread_alias',[Id0|Id],_), + '$valid_thread'(Id0), !, '$detach_thread'(Id0). +thread_detach(Id) :- + integer(Id), + '$valid_thread'(Id), !, + '$detach_thread'(Id0). +thread_detach(Id) :- + '$do_error'(existence_error(thread, Id),thread_detach(Id)). thread_exit(Term) :- '$thread_self'(Id0),