| 1 | <?php |
||
| 11 | class Semaphore |
||
| 12 | { |
||
| 13 | use IpcKeyTrait; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Whether the semaphore is locked |
||
| 17 | * @var boolean |
||
| 18 | */ |
||
| 19 | protected $locked; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * The resource that can be used to access the System V semaphore |
||
| 23 | * @var resource |
||
| 24 | */ |
||
| 25 | protected $semId; |
||
| 26 | |||
| 27 | public function __construct($pathname = __FILE__, $maxAcquireNum = 1, $permission = 0666) |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Acquires the lock |
||
| 37 | * @param bool $blocking |
||
| 38 | * @return bool |
||
| 39 | */ |
||
| 40 | public function acquire($blocking = true) |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Release the lock |
||
| 59 | * @return bool |
||
| 60 | */ |
||
| 61 | public function release() |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Destroy semaphore |
||
| 72 | * @return void |
||
| 73 | */ |
||
| 74 | public function destroy() |
||
| 78 | } |
||
| 79 |