From 4c933b8d79eba0e1d3956a061231604345f23bc6 Mon Sep 17 00:00:00 2001 From: vsc Date: Fri, 4 Apr 2008 10:02:44 +0000 Subject: [PATCH] implement thread_cancel using signals use duplicate_term instead of copy_term in throw: throw may lose reference to term. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2207 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- pl/boot.yap | 2 +- pl/errors.yap | 8 +++++++- pl/threads.yap | 6 +----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pl/boot.yap b/pl/boot.yap index a83dfabdc..1815f77f1 100644 --- a/pl/boot.yap +++ b/pl/boot.yap @@ -1120,7 +1120,7 @@ catch(G, C, A) :- % throw(Ball) :- % get this off the unwound computation. - copy_term(Ball,NewBall), + duplicate_term(Ball,NewBall), % get current jump point '$jump_env_and_store_ball'(NewBall). diff --git a/pl/errors.yap b/pl/errors.yap index d82c60f9f..0d419024b 100644 --- a/pl/errors.yap +++ b/pl/errors.yap @@ -11,8 +11,11 @@ * File: errors.yap * * comments: error messages for YAP * * * -* Last rev: $Date: 2008-03-17 12:08:28 $,$Author: vsc $ * +* Last rev: $Date: 2008-04-04 10:02:44 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.87 2008/03/17 12:08:28 vsc +* avoid silly message +* * Revision 1.86 2008/02/23 01:32:31 vsc * fix chr bootstrap. * @@ -205,6 +208,9 @@ print_message(informational,abort(user)). '$process_error'(abort, _) :- !, throw('$abort'). +'$process_error'(error(thread_cancel(Id), G),top) :- !. +'$process_error'(error(thread_cancel(Id), G), _) :- !, + throw(error(thread_cancel(Id), G)). '$process_error'(error(Msg, Where), _) :- !, '$set_fpu_exceptions', print_message(error,error(Msg, Where)). diff --git a/pl/threads.yap b/pl/threads.yap index 9eca1fa0b..709f10070 100644 --- a/pl/threads.yap +++ b/pl/threads.yap @@ -319,11 +319,7 @@ thread_cancel(Id) :- (Id == main; Id == 0), !, '$do_error'(permission_error(cancel, thread, main), thread_cancel(Id)). thread_cancel(Id) :- - '$check_thread_or_alias'(Id, thread_cancel(Id)), - '$thread_id_alias'(Id0, Id), - '$unlock_all_thread_mutexes'(Id0), - '$erase_thread_info'(Id0), - '$thread_destroy'(Id0). + thread_signal(Id, throw(error(thread_cancel(Id),thread_cancel(Id)))). thread_detach(Id) :- '$check_thread_or_alias'(Id, thread_detach(Id)),