Sync
final class Sync (View source)
The Sync class provides access to low level synchronization primitives, mutex, condition variables, and allows the implementation of semaphores.
Synchronization for most applications is much better implemented using channels, however, in some cases authors of low level code may find it useful to be able to access these lower level mechanisms.
Methods
Shall construct a new synchronization object with no value Shall construct a new synchronization object containing the given scalar value
Shall atomically return the synchronization objects value
Shall atomically set the value of the synchronization object
Shall wait for notification on this synchronization object
Shall notify one (by default) or all threads waiting on the synchronization object
Shall exclusively enter into the critical code
Details
__construct(string|int|float|bool $value = null)
Shall construct a new synchronization object with no value Shall construct a new synchronization object containing the given scalar value
string|int|float|bool
get()
Shall atomically return the synchronization objects value
set(string|int|float|bool $value)
Shall atomically set the value of the synchronization object
bool
wait()
Shall wait for notification on this synchronization object
bool
notify(bool $all = null)
Shall notify one (by default) or all threads waiting on the synchronization object
__invoke(callable $block)
Shall exclusively enter into the critical code