Mutex: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
(Added Prolog)
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 67:
end;</lang>
It is also possible to implement mutex as a monitor task.
 
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
Line 457 ⟶ 458:
 
</lang>
 
=={{header|Java}}==
{{works with|Java|1.5+}}
Line 522 ⟶ 524:
 
The "synchronized" keyword actually is a form of [[monitor]], which was a later-proposed solution to the same problems that mutexes and semaphores were designed to solve. More about synchronization may be found on Sun's website - http://java.sun.com/docs/books/tutorial/essential/concurrency/sync.html , and more about monitors may be found in any decent operating systems textbook.
 
 
=={{header|Julia}}==
Line 551 ⟶ 552:
<lang julia>ReentrantLock()</lang>
Creates a re-entrant lock for synchronizing Tasks. The same task can acquire the lock as many times as required. Each lock must be matched with an unlock.
 
 
=={{header|Logtalk}}==
Line 685:
# Trying to lock (but do not wait if it can't)
<lang nim>let success = tryAcquire mutex</lang>
 
=={{header|Objeck}}==
Objeck provides a simple way to lock a section of code. Please refer to the [[Objeck|programer's guide]] for addition information.
 
<lang objeck>
m := ThreadMutex->New("lock a");
# section locked
critical(m) {
...
# section unlocked
</lang>
 
=={{header|Objective-C}}==
Line 703 ⟶ 715:
 
Objective-C also has [http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocThreading.html#//apple_ref/doc/uid/TP30001163-CH19-BCIIGGHG @synchronized() blocks], like Java.
 
=={{header|Objeck}}==
Objeck provides a simple way to lock a section of code. Please refer to the [[Objeck|programer's guide]] for addition information.
 
<lang objeck>
m := ThreadMutex->New("lock a");
# section locked
critical(m) {
...
# section unlocked
</lang>
 
=={{header|OCaml}}==
Line 804:
}</lang>
 
=={{header|Perl 6}}==
<lang perl6>my $lock = Lock.new;
 
$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
Line 949 ⟶ 944:
Some notable examples:
OS semaphore for use with OS threads, green threads, lightweight OS threads, and heavyweight OS threads, synchronization channels, thread mailboxes, CML-style event handling, generic synchronizeable event objects, non-blocking IO, etc, etc.
 
=={{header|Perl 6Raku}}==
(formerly Perl 6)
<lang perl6>my $lock = Lock.new;
 
$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|Ruby}}==
10,333

edits