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),