Jump to content

Mutex: Difference between revisions

(julia example)
Line 809:
$lock.protect: { your-ad-here() }</lang>
Locks are reentrant. You may explicitly lock and unlock them, but the syntax above guarantees the lock will be unlocked on scope exit, even if by thrown exception or other exotic control flow. That being said, direct use of locks is discouraged in Perl 6 in favor of promises, channels, and supplies, which offer better composable semantics.
=={{header|Phix}}==
<lang Phix>integer cs = init_cs() -- Create a new critical section
enter_cs(cs) -- Begin mutually exclusive execution
bool b = try_cs(cs) -- As enter_cs, but yields false (0) if the lock cannot be obtained instantly
leave_cs(cs) -- End mutually exclusive execution
delete_cs(cs) -- Delete a critical section that you have no further use for</lang>
 
=={{header|PicoLisp}}==
PicoLisp uses several mechanisms of interprocess communication, mainly within
7,815

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.