diff --git a/src/Lock.php b/src/Lock.php index b9484e2..79869db 100644 --- a/src/Lock.php +++ b/src/Lock.php @@ -55,10 +55,11 @@ abstract protected function getCurrentOwner(); /** * Attempt to acquire the lock - * @param null $callback + * @param null|\Closure $callback + * @param null|\Closure $finally * @return bool|mixed */ - public function get($callback = null) + public function get($callback = null, $finally = null) { $result = $this->acquire(); if($result && is_callable($callback)) { @@ -68,6 +69,9 @@ public function get($callback = null) $this->release(); } } + if (!$result && is_callable($finally)) { + return $finally(); + } return $result; }