inc/semaphore.php
Protects critical sections from concurrency, when exclusive file access is needed.
Function
swSemaphoreSignal()
Reserves exclusive access. The reservation is signalled with an empty file site/indexes/semaphore.php
If the file exists already, the function sleeps for at most $swSemaphoreTimeOut (default 15), then it overrides and proceeds.
(Timeout is needed, as a PHP thread my forget to release.
A global variable $swSemaphore overrides blocking, so it cannot block itself
swSemaphoreRelease()
Releases access.
Sempahore is used in the following functions:
- db->RebuildIndexes()
- db->RebuldBitmaps()
- swBackup()
- swExport()
- swFilter()
- swSnapshot();
- swPersistance->save();
- swRecord->WriteCurrent()
- swRecord->WriteFile()
Others may be needed.
You can use it also in you apps. Don't forget to pair signal with release.