Commit 90227bd3 by resurtm

Autorelease callback improved, composer.json typo.

parent 397004c8
...@@ -22,6 +22,6 @@ ...@@ -22,6 +22,6 @@
"yiisoft/yii2": "*" "yiisoft/yii2": "*"
}, },
"autoload": { "autoload": {
"psr-0": { "yii\\smarty": "" } "psr-0": { "yii\\mutex": "" }
} }
} }
...@@ -33,7 +33,13 @@ abstract class Mutex extends Component ...@@ -33,7 +33,13 @@ abstract class Mutex extends Component
public function init() public function init()
{ {
if ($this->autoRelease) { if ($this->autoRelease) {
register_shutdown_function(array($this, 'shutdownFunction')); $referenceHolder = new stdClass();
$referenceHolder->locks = &$this->_locks;
register_shutdown_function(function ($ref) {
foreach ($ref->locks as $lock) {
$this->release($lock);
}
}, $referenceHolder);
} }
} }
...@@ -42,9 +48,7 @@ abstract class Mutex extends Component ...@@ -42,9 +48,7 @@ abstract class Mutex extends Component
*/ */
public function shutdownFunction() public function shutdownFunction()
{ {
foreach ($this->_locks as $lock) {
$this->release($lock);
}
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment