We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6715a32 commit 48ca12aCopy full SHA for 48ca12a
src/Lock.php
@@ -55,10 +55,11 @@ abstract protected function getCurrentOwner();
55
56
/**
57
* Attempt to acquire the lock
58
- * @param null $callback
+ * @param null|\Closure $callback
59
+ * @param null|\Closure $finally
60
* @return bool|mixed
61
*/
- public function get($callback = null)
62
+ public function get($callback = null, $finally = null)
63
{
64
$result = $this->acquire();
65
if($result && is_callable($callback)) {
@@ -68,6 +69,9 @@ public function get($callback = null)
68
69
$this->release();
70
}
71
72
+ if (!$result && is_callable($finally)) {
73
+ return $finally();
74
+ }
75
76
return $result;
77
0 commit comments