fix threads/0.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2302 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
5776abb31c
commit
b3a0b412f1
16
C/threads.c
16
C/threads.c
@ -479,7 +479,20 @@ p_thread_detach(void)
|
||||
static Int
|
||||
p_thread_detached(void)
|
||||
{
|
||||
return Yap_unify(ARG1,ThreadHandle[worker_id].tdetach);
|
||||
if (ThreadHandle[worker_id].tdetach)
|
||||
return Yap_unify(ARG1,ThreadHandle[worker_id].tdetach);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_detached2(void)
|
||||
{
|
||||
Int tid = IntegerOfTerm(Deref(ARG1));
|
||||
if (ThreadHandle[tid].tdetach)
|
||||
return Yap_unify(ARG2,ThreadHandle[tid].tdetach);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static Int
|
||||
@ -820,6 +833,7 @@ void Yap_InitThreadPreds(void)
|
||||
Yap_InitCPred("thread_yield", 0, p_thread_yield, 0);
|
||||
Yap_InitCPred("$detach_thread", 1, p_thread_detach, HiddenPredFlag);
|
||||
Yap_InitCPred("$thread_detached", 1, p_thread_detached, HiddenPredFlag);
|
||||
Yap_InitCPred("$thread_detached", 2, p_thread_detached2, HiddenPredFlag);
|
||||
Yap_InitCPred("$thread_exit", 0, p_thread_exit, HiddenPredFlag);
|
||||
Yap_InitCPred("thread_setconcurrency", 2, p_thread_set_concurrency, 0);
|
||||
Yap_InitCPred("$valid_thread", 1, p_valid_thread, HiddenPredFlag);
|
||||
|
@ -807,12 +807,24 @@ thread_property(Prop) :-
|
||||
thread_property(Id, Prop) :-
|
||||
( nonvar(Id) ->
|
||||
'$check_thread_or_alias'(Id, thread_property(Id, Prop))
|
||||
; '$thread_stacks'(Id, _, _, _)
|
||||
; '$enumerate_threads'(Id)
|
||||
),
|
||||
'$check_thread_property'(Prop, thread_property(Id, Prop)),
|
||||
'$thread_id_alias'(Id0, Id),
|
||||
'$thread_property'(Id0, Prop).
|
||||
|
||||
'$enumerate_threads'(Id) :-
|
||||
'$max_threads'(Max),
|
||||
Max1 is Max-1,
|
||||
'$between'(0,Max1,Id),
|
||||
'$thread_stacks'(Id, _, _, _).
|
||||
|
||||
'$between'(I,_,I).
|
||||
'$between'(I0,I,J) :-
|
||||
I0 < I,
|
||||
I1 is I0+1,
|
||||
'$between'(I1,I,J).
|
||||
|
||||
'$thread_property'(Id, alias(Alias)) :-
|
||||
recorded('$thread_alias', [Id|Alias], _).
|
||||
'$thread_property'(Id, status(Status)) :-
|
||||
@ -822,7 +834,7 @@ thread_property(Id, Prop) :-
|
||||
; Status = running
|
||||
).
|
||||
'$thread_property'(Id, detached(Detached)) :-
|
||||
'$thread_detached'(Detached).
|
||||
'$thread_detached'(Id,Detached).
|
||||
'$thread_property'(Id, at_exit(M:G)) :-
|
||||
'$thread_run_at_exit'(G,M).
|
||||
'$thread_property'(Id, InfoSize) :-
|
||||
@ -837,7 +849,7 @@ threads :-
|
||||
format(user_error,'------------------------------------------------------------------------~n',[]),
|
||||
format(user_error, '~t~a~48+~n', 'Thread Detached Status'),
|
||||
format(user_error,'------------------------------------------------------------------------~n',[]),
|
||||
'$thread_property'(Id, detached(Detached)),
|
||||
thread_property(Id, detached(Detached)),
|
||||
'$thread_property'(Id, status(Status)),
|
||||
'$thread_id_alias'(Id, Alias),
|
||||
format(user_error,'~t~q~30+~33|~w~42|~q~n', [Alias, Detached, Status]),
|
||||
|
Reference in New Issue
Block a user