From 50e39bef80ee50b696a673d0ad49285d1e4d0ff4 Mon Sep 17 00:00:00 2001 From: pmoura Date: Tue, 19 Jun 2007 10:55:35 +0000 Subject: [PATCH] Added the thread_create/1 built-in predicate specified in the ISO standardization proposal. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1904 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- docs/yap.tex | 7 +++++++ pl/threads.yap | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/docs/yap.tex b/docs/yap.tex index 2b5561b33..5d0970be5 100644 --- a/docs/yap.tex +++ b/docs/yap.tex @@ -10628,6 +10628,13 @@ data from their stacks. Create a new Prolog thread using default options. See @code{thread_create/3}. +@item thread_create(:@var{Goal}) +@findex thread_create/1 +@snindex thread_create/1 +@cnindex thread_create/1 + +Create a new Prolog detached thread using default options. See @code{thread_create/3}. + @item thread_self(-@var{Id}) @findex thread_self/1 @snindex thread_self/1 diff --git a/pl/threads.yap b/pl/threads.yap index 6a549fe07..0ece84a76 100644 --- a/pl/threads.yap +++ b/pl/threads.yap @@ -18,6 +18,7 @@ :- meta_predicate thread_create(:,-,+), thread_create(:,-), + thread_create(:), thread_at_exit(:), thread_signal(+,:), with_mutex(+,:). @@ -57,6 +58,16 @@ ), '$run_at_thread_exit'(Id0). +thread_create(Goal) :- + G0 = thread_create(Goal), + '$check_callable'(Goal, G0), + '$thread_options'([detached(true)], [], Stack, Trail, System, Detached, G0), + '$thread_new_tid'(Id), + '$erase_thread_info'(Id), + '$record_thread_info'(Id, [Stack, Trail, System], true), + '$create_mq'(Id), + '$create_thread'(Goal, Stack, Trail, System, Detached, Id). + thread_create(Goal, Id) :- G0 = thread_create(Goal, Id), '$check_callable'(Goal, G0),