F /55.5.0+dev0-2025-04-28/)Semaphoreӱ(CountingA@!tB;@@@A@@@@@:../../stdlib/semaphore.mlin55n5;@@@@)Semaphore@@A@$make@#int@@@)Semaphore (Counting!t@@@@@@qeeqex@@A@@'release@)Semaphore!(Counting!t@@@$unit"@@@@@@8x  9x  2@@7B@@'acquire@)Semaphore#(Counting!t@@@$@@@@@@RB  SB  @@QC@@+try_acquire@)Semaphore%(Counting!t@@@$bool&@@@@@@mG P PnG P k@@lD@@)get_value@)Semaphore'(Counting!t@@@u(@@@@@@M * *M * B@@E@@@@lU n q@F@@@ӱ&BinaryC@!tD;@@A@@@@@pNNpNT@@@@G@A@$make@>)@@@)Semaphore*&Binary!t@@@@@@s||s|@@H@@'release@)Semaphore+&Binary!t@@@,@@@@@@zrrzr@@I@@'acquire@)Semaphore-&Binary!t@@@.@@@@@@111H@@J@@+try_acquire@)Semaphore/&Binary!t@@@0@@@@@@@@K@@@@n99@L@@@@3*Semaphores@ l A semaphore is a thread synchronization device that can be used to control access to a shared resource.@ W Two flavors of semaphores are provided: counting semaphores and binary semaphores.@@@@$4.12@@@@@@@A:../../stdlib/semaphore.mliB@3Counting semaphores@@ A counting semaphore is a counter that can be accessed concurrently by several threads. The typical use is to synchronize producers and consumers of a resource by counting how many units of the resource are available.@ . The two basic operations on semaphores are: "release" (also called "V", "post", "up", and "signal"), which increments the value of the counter. This corresponds to producing one more unit of the shared resource and making it available to others.@ "acquire" (also called "P", "wait", "down", and "pend"), which waits until the counter is greater than zero and decrements it. This corresponds to consuming one unit of the shared resource.@@@/2Semaphore.CountingA@A #4Semaphore.Counting.t3 The type of counting semaphores.@@@@@@@@@@@@@@A@@GE@@7Semaphore.Counting.make3&make n 6 returns a new counting semaphore, with initial value !n8. The initial value !n5 must be nonnegative.@@@@@@@@0Invalid_argument#if %n < 0@@@@@_@ a@@@@S:Semaphore.Counting.release3)release s # increments the value of semaphore !s &. If other threads are waiting on !s 8, one of them is restarted. If the current value of !s- is equal to 'max_int 4, the value of the semaphore is unchanged and a )Sys_error , exception is raised to signal overflow.@@@@@@@@)Sys_error -if the value of the semaphore would overflow 'max_int@@@@@~@:@@@@q:Semaphore.Counting.acquire3)acquire s 8 blocks the calling thread until the value of semaphore !s : is not zero, then atomically decrements the value of !s- and returns.@@@@@@@@@@@@@X@@@@u>Semaphore.Counting.try_acquire3-try_acquire s5 immediately returns %false; if the value of semaphore !s ' is zero. Otherwise, the value of !s # is atomically decremented and -try_acquire s) returns $true!.@@@@@@@@@@@@@@@@@The type of binary semaphores.@@@@@@@@@@@@@@A@@@@5Semaphore.Binary.make3&make b ( returns a new binary semaphore. If !b$ is $true H, the initial value of the semaphore is 1, meaning "available". If !b$ is %false E, the initial value of the semaphore is 0, meaning "unavailable".@@@@@@@@@@@@@@@@@ʠ8Semaphore.Binary.release3)release s= sets the value of semaphore !s Q to 1, putting it in the "available" state. If other threads are waiting on !s?, one of them is restarted.@@@@@@@@@@@@@-@@@@Π8Semaphore.Binary.acquire3)acquire s / blocks the calling thread until the semaphore !s N has value 1 (is available), then atomically sets it to 0 and returns.@@@@@@@@@@@@@E@@@@̠