Class SyncCounter[in Threading]

Implements a synchronization counter (semaphore).

class SyncCounter( [count] )

more...

Summary

post()Releases the counter or increases the counter by more than one.

Detailed description

class SyncCounter( [count] )

countInitial counter value (defaults to 0).

Implements a synchronization counter (semaphore).

This class implements a synchronization counter, commonly known as "semaphore", which provides the following behavior:

We have adopted the "counter" name rather than the more common "semaphore" to avoid confusion with the Semaphore class used for coroutines, and also because the post semantic is merged with the release method.

The counter is created with an initial count that defaults to zero; this means that the first thread trying to acquire this structure will block until a post or release is issued.

If a positive interger is given as count, then the same amount of threads will be able to acquire the semaphore before one thread being blocked.

Methods

post()

Releases the counter or increases the counter by more than one.

SyncCounter.post( [count] )

countThe number of signals to be posted to this semaphore.

This method acts as release(), but it can be provided an optional parameter to give more than one thread the ability to acquire this structure.

It is not possible to use this method to reduce the internal count.


Made with faldoc 2.2.1