SyncTable of Contents
The SyncMutex classIntroductionA cross-platform, native implementation of named and unnamed countable mutex objects. A mutex is a mutual exclusion object that restricts access to a shared resource (e.g. a file) to a single instance. Countable mutexes acquire the mutex a single time and internally track the number of times the mutex is locked. The mutex is unlocked as soon as it goes out of scope or is unlocked the same number of times that it was locked. Class synopsisSyncMutex
class SyncMutex
{
/* Methods */
public __construct
([ string
$name
] )
public bool lock
([ integer
$wait = -1
] )
public bool unlock
([ bool
}$all = false
] )The SyncSemaphore classIntroductionA cross-platform, native implementation of named and unnamed sempahore objects. A semaphore restricts access to a limited resource to a limited number of instances. Semaphores differ from mutexes in that they can allow more than one instance to access a resource at one time while a mutex only allows one instance at a time. Class synopsisSyncSemaphore
class SyncSemaphore
{
/* Methods */
public __construct
([ string
$name
[, integer $initialval = 1
[, bool $autounlock = true
]]] )
public bool lock
([ integer
$wait = -1
] )
public bool unlock
([ integer
}&$prevcount
] )The SyncEvent classIntroductionA cross-platform, native implementation of named and unnamed event objects. Both automatic and manual event objects are supported. An event object waits, without polling, for the object to be fired/set. One instance waits on the event object while another instance fires/sets the event. Event objects are useful wherever a long-running process would otherwise poll a resource (e.g. checking to see if uploaded data needs to be processed). Class synopsisSyncEvent
class SyncEvent
{
/* Methods */
public __construct
([ string
$name
[, bool $manual = false
[, bool $prefire = false
]]] )
public bool fire
( void
)
public bool reset
( void
)
public bool wait
([ integer
}$wait = -1
] )The SyncReaderWriter classIntroductionA cross-platform, native implementation of named and unnamed reader-writer objects. A reader-writer object allows many readers or one writer to access a resource. This is an efficient solution for managing resources where access will primarily be read-only but exclusive write access is occasionally necessary. Class synopsisSyncReaderWriter
class SyncReaderWriter
{
/* Methods */
public __construct
([ string
$name
[, bool $autounlock = true
]] )
public bool readlock
([ integer
$wait = -1
] )
public bool readunlock
( void
)
public bool writelock
([ integer
$wait = -1
] )
public bool writeunlock
( void
)
}The SyncSharedMemory class |