Code: Select all
class perThreadVarM{@Term} : varM{@Term}
end class perThreadVarM
%---
implement perThreadVarM{@Term}
facts
varMapM : mapM{multiThread_native::threadId ThreadId, varM{@Term}} := mapM_redBlack_cas::new() [immediate].
clauses
new() :-
ThreadHandle = multiThread_native::getCurrentThread(),
ThreadID = multiThread_native::getThreadID(ThreadHandle),
VarM = varM::new_erroneous(),
varMapM:set(ThreadId, VarM),
ActualThreadHandle = multiThread_api::mkNonInheritable(ThreadHandle, :CloseOriginal = false),
SyncObject = syncObject::new(ActualThreadHandle, :NeedRelease = false),
_Future =
pfc\asynchronous\future::submit_unit(
{ :-
_ = SyncObject:waitAsync(),
SyncObject:close(),
varMapM:removeKey(ThreadID)
},
:Ctx = pfc\asynchronous\executionContext_pool::defaultPool).
properties
varM : varM{@Term} (o).
clauses
varM() = varMapM:get(multiThread_native::getCurrentThreadId()).
delegate
interface varM{@Term} to varM
end implement perThreadVarM
Code: Select all
class facts
myPerThreadVarM : varM{string} := perThreadVarM::new().