boo1ean/semaphore

Don't let your app be afraid of parallel execution

Installs: 7

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/boo1ean/semaphore

dev-master 2013-12-11 11:07 UTC

This package is not auto-updated.

Last update: 2025-10-07 12:05:36 UTC


README

This package provide simple semaphore wrapper which can work different adapters

Basic usage

<?php

use Semaphore\Semaphore;

$lock = new Semaphore();
$key  = 'oh no!';

if ($lock->locked($key) {
	// Meh, it's so locked...
} else {
	// Lock semaphore
	$lock->lock($key);

	// Do thread-safe operations
	reallyImportantCriticalStuff();

	// Release lock
	$lock->unlock($key);
}