Browse Source

Autorelease callback improved, composer.json typo.

tags/2.0.0-beta
resurtm 12 years ago
parent
commit
90227bd344
  1. 2
      extensions/mutex/composer.json
  2. 12
      extensions/mutex/yii/mutex/Mutex.php

2
extensions/mutex/composer.json

@ -22,6 +22,6 @@
"yiisoft/yii2": "*" "yiisoft/yii2": "*"
}, },
"autoload": { "autoload": {
"psr-0": { "yii\\smarty": "" } "psr-0": { "yii\\mutex": "" }
} }
} }

12
extensions/mutex/yii/mutex/Mutex.php

@ -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
*/ */
public function shutdownFunction() public function shutdownFunction()
{ {
foreach ($this->_locks as $lock) {
$this->release($lock);
}
} }
/** /**

Loading…
Cancel
Save