Implemented the predicate with_mutex/2.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1751 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
7d1b20c9cd
commit
8ddee740a4
@ -16,8 +16,9 @@
|
|||||||
|
|
||||||
<h2>Yap-5.1.2:</h2>
|
<h2>Yap-5.1.2:</h2>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li> NEW: with_mutex/2.</li>
|
||||||
<li> NEW: call_cleanup/2 and call_cleanup/3 at the request of Paulo
|
<li> NEW: call_cleanup/2 and call_cleanup/3 at the request of Paulo
|
||||||
Moura and Christian1.</li>
|
Moura and Christian.</li>
|
||||||
<li> FIXED: garbage collector would not understand bindings to mavars in
|
<li> FIXED: garbage collector would not understand bindings to mavars in
|
||||||
tabling version.</li>
|
tabling version.</li>
|
||||||
<li> FIXED: cut might not prune correctly around meta-call (obs by
|
<li> FIXED: cut might not prune correctly around meta-call (obs by
|
||||||
|
@ -335,7 +335,28 @@ mutex_unlock_all.
|
|||||||
NRefs > 0,
|
NRefs > 0,
|
||||||
'$unlock_mutex'(Id),
|
'$unlock_mutex'(Id),
|
||||||
'$mutex_unlock_all'(Id).
|
'$mutex_unlock_all'(Id).
|
||||||
|
|
||||||
|
with_mutex(M, G) :-
|
||||||
|
var(M), !,
|
||||||
|
'$do_error'(instantiation_error,with_mutex(M, G)).
|
||||||
|
with_mutex(M, G) :-
|
||||||
|
var(G), !,
|
||||||
|
'$do_error'(instantiation_error,with_mutex(M, G)).
|
||||||
|
with_mutex(M, G) :-
|
||||||
|
\+ callable(G),
|
||||||
|
'$do_error'(type_error(callable,G),with_mutex(M, G)).
|
||||||
|
with_mutex(M, G) :-
|
||||||
|
atom(M), !,
|
||||||
|
( recorded('$mutex',[M|Id],_) ->
|
||||||
|
true
|
||||||
|
; '$new_mutex'(Id),
|
||||||
|
recorda('$mutex',[M|Id],_)
|
||||||
|
),
|
||||||
|
'$lock_mutex'(Id),
|
||||||
|
call_cleanup(once(G), '$unlock_mutex'(Id)).
|
||||||
|
with_mutex(M, G) :-
|
||||||
|
'$do_error'(type_error(atom,M),with_mutex(M, G)).
|
||||||
|
|
||||||
current_mutex(M, T, NRefs) :-
|
current_mutex(M, T, NRefs) :-
|
||||||
recorded('$mutex',[M|Id],_),
|
recorded('$mutex',[M|Id],_),
|
||||||
'$mutex_info'(Id, NRefs, T).
|
'$mutex_info'(Id, NRefs, T).
|
||||||
|
Reference in New Issue
Block a user