Metered concurrency: Difference between revisions

Content deleted Content added
m →‎[[Java]]: Use Java header instead
m Switch to header template
Line 3:
The goal of this task is to create a [http://en.wikipedia.org/wiki/Counting_semaphore counting semaphore] used to control the execution of a set of concurrent units. This task intends to demonstrate coordination of active concurrent units through the use of a passive concurrent unit. The operations for a counting semaphore are ''acquire'', ''release'', and ''count''. Each active concurrent unit should attempt to acquire the counting semaphore before executing its assigned duties. In this case the active concurrent unit should report that it has acquired the semaphore. It should sleep for 2 seconds and then release the semaphore.
 
==[[{{header|Ada]]}}==
[[Category:Ada]]
'''Compiler: GNAT''' GPL 2006
 
Line 97 ⟶ 96:
end Semaphores_Main;
 
==[[{{header|E]]}}==
[[Category:E]]
 
This semaphore slightly differs from the task description; the release operation is not on the semaphore itself but given out with each acquisition, and cannot be invoked too many times.
 
Line 218 ⟶ 215:
}
 
==[[{{header|Perl]]}}==
[[Category:Perl]]
See [http://search.cpan.org/dist/Coro/Coro/Semaphore.pm Coro::Semaphore].
 
==[[{{header|Python]]}}==
[[Category: Python]]
 
Python threading module includes a semaphore implementation. This code show how to use it.
 
Line 267 ⟶ 261:
</pre>
 
==[[{{header|Raven]]}}==
[[Category:Raven]]
 
Counting semaphores are built in: