Skip to content

Commit 48ca12a

Browse files
committed
[feature] finally return Closure added
1 parent 6715a32 commit 48ca12a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Lock.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ abstract protected function getCurrentOwner();
5555

5656
/**
5757
* Attempt to acquire the lock
58-
* @param null $callback
58+
* @param null|\Closure $callback
59+
* @param null|\Closure $finally
5960
* @return bool|mixed
6061
*/
61-
public function get($callback = null)
62+
public function get($callback = null, $finally = null)
6263
{
6364
$result = $this->acquire();
6465
if($result && is_callable($callback)) {
@@ -68,6 +69,9 @@ public function get($callback = null)
6869
$this->release();
6970
}
7071
}
72+
if (!$result && is_callable($finally)) {
73+
return $finally();
74+
}
7175

7276
return $result;
7377
}

0 commit comments

Comments
 (0)