1 | <?php |
||
17 | class FlockLock extends LockAbstract |
||
18 | { |
||
19 | protected $dirname; |
||
20 | protected $files = array(); |
||
21 | |||
22 | /** |
||
23 | * @param string $dirname |
||
24 | */ |
||
25 | public function __construct($dirname) |
||
31 | |||
32 | /** |
||
33 | * @param string $name |
||
34 | * @param bool $blocking |
||
35 | * @return bool |
||
36 | */ |
||
37 | protected function getLock($name, $blocking) |
||
56 | |||
57 | /** |
||
58 | * Release lock |
||
59 | * |
||
60 | * @param string $name name of lock |
||
61 | * @return bool |
||
62 | */ |
||
63 | public function releaseLock($name) |
||
76 | |||
77 | /** |
||
78 | * @param string $name |
||
79 | * @return string |
||
80 | */ |
||
81 | protected function getFilePath($name) |
||
85 | |||
86 | /** |
||
87 | * @param string $name |
||
88 | * @return bool |
||
89 | */ |
||
90 | protected function setupFileHandle($name) |
||
105 | |||
106 | public function __clone() |
||
111 | |||
112 | /** |
||
113 | * Try to release any obtained locks when object is destroyed |
||
114 | * |
||
115 | * This is a safe guard for cases when your php script dies unexpectedly. |
||
116 | * It's not guaranteed it will work either. |
||
117 | * |
||
118 | * You should not depend on __destruct() to release your locks, |
||
119 | * instead release them with `$released = $this->releaseLock()`A |
||
120 | * and check `$released` if lock was properly released |
||
121 | */ |
||
122 | public function __destruct() |
||
128 | |||
129 | /** |
||
130 | * Check if lock is locked |
||
131 | * |
||
132 | * @param string $name name of lock |
||
133 | * @return bool |
||
134 | */ |
||
135 | public function isLocked($name) |
||
143 | } |
||
144 |