1. Go to this page and download the library: Download php-win-ext/sync library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
php-win-ext / sync example snippets
$mutex = new SyncMutex();
$mutex->lock();
...
$mutex->unlock();
$mutex2 = new SyncMutex("UniqueName");
if (!$mutex2->lock(3000))
{
echo "Unable to lock mutex.";
exit();
}
...
$mutex2->unlock();
$semaphore = new SyncSemaphore("LimitedResource_2_clients", 2);
if (!$semaphore->lock(3000))
{
echo "Unable to lock semaphore.";
exit();
}
...
$semaphore->unlock();
// In a web application:
$event = new SyncEvent("GetAppReport");
$event->fire();
// In a cron job:
$event = new SyncEvent("GetAppReport");
$event->wait();
$readwrite = new SyncReaderWriter("FileCacheLock");
$readwrite->readlock();
...
$readwrite->readunlock();
$readwrite->writelock();
...
$readwrite->writeunlock();
// You will probably need to protect shared memory with other synchronization objects.
// Shared memory goes away when the last reference to it disappears.
$mem = new SyncSharedMemory("AppReportName", 1024);
if ($mem->first())
{
// Do first time initialization work here.
}
$result = $mem->write(json_encode(array("name" => "my_report.txt")));
bash
pie install php-win-ext/sync
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.