Conditions | 4 |
Paths | 5 |
Total Lines | 16 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
40 | public function acquire($blocking = true) |
||
41 | { |
||
42 | //non-blocking requires php version greater than 5.6.1 |
||
43 | if (!$blocking) { |
||
44 | if (version_compare(PHP_VERSION, '5.6.1') < 0) { |
||
45 | throw new InvalidArgumentException("Semaphore requires php version greater than 5.6.1 when using blocking"); |
||
46 | } |
||
47 | $result = sem_acquire($this->semId, !$blocking); |
||
48 | } else { |
||
49 | $result = sem_acquire($this->semId); |
||
50 | } |
||
51 | if ($result) { |
||
52 | $this->locked = true; |
||
53 | } |
||
54 | return $result; |
||
55 | } |
||
56 | |||
79 |