Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
b98a1236
Commit
b98a1236
authored
Jun 25, 2013
by
resurtm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes:
1. Proper auto release shutdown callback. 2. Proper Mutex::releaseLock() method.
parent
33adfcea
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
18 deletions
+13
-18
Mutex.php
extensions/mutex/yii/mutex/Mutex.php
+13
-18
No files found.
extensions/mutex/yii/mutex/Mutex.php
View file @
b98a1236
...
@@ -33,26 +33,18 @@ abstract class Mutex extends Component
...
@@ -33,26 +33,18 @@ abstract class Mutex extends Component
public
function
init
()
public
function
init
()
{
{
if
(
$this
->
autoRelease
)
{
if
(
$this
->
autoRelease
)
{
$reference
Holder
=
new
stdClass
();
$reference
s
=
new
stdClass
();
$reference
Holder
->
mutex
=
&
$this
;
$reference
s
->
mutex
=
$this
;
$reference
Holder
->
locks
=
&
$this
->
_locks
;
$reference
s
->
locks
=
&
$this
->
_locks
;
register_shutdown_function
(
function
(
$ref
)
{
register_shutdown_function
(
function
(
$ref
s
)
{
foreach
(
$ref
->
locks
as
$lock
)
{
foreach
(
$ref
s
->
locks
as
$lock
)
{
$ref
->
mutex
->
release
(
$lock
);
$ref
s
->
mutex
->
release
(
$lock
);
}
}
},
$reference
Holder
);
},
$reference
s
);
}
}
}
}
/**
/**
* Never call this method directly under any circumstances. This method is intended for internal use only.
*/
public
function
shutdownFunction
()
{
}
/**
* @param string $name of the lock to be acquired. Must be unique.
* @param string $name of the lock to be acquired. Must be unique.
* @param integer $timeout to wait for lock to be released. Defaults to zero meaning that method will return
* @param integer $timeout to wait for lock to be released. Defaults to zero meaning that method will return
* false immediately in case lock was already acquired.
* false immediately in case lock was already acquired.
...
@@ -69,14 +61,17 @@ abstract class Mutex extends Component
...
@@ -69,14 +61,17 @@ abstract class Mutex extends Component
}
}
/**
/**
* Release acquired lock.
* Release acquired lock.
This method will return false in case named lock was not found.
* @param string $name of the lock to be released. This lock must be already created.
* @param string $name of the lock to be released. This lock must be already created.
* @return boolean lock release result.
* @return boolean lock release result
: false in case named lock was not found.
.
*/
*/
public
function
releaseLock
(
$name
)
public
function
releaseLock
(
$name
)
{
{
if
(
$this
->
release
(
$name
))
{
if
(
$this
->
release
(
$name
))
{
unset
(
$this
->
_locks
[
array_search
(
$name
,
$this
->
_locks
)]);
$index
=
array_search
(
$name
,
$this
->
_locks
);
if
(
$index
!==
false
)
{
unset
(
$this
->
_locks
[
$index
]);
}
return
true
;
return
true
;
}
else
{
}
else
{
return
false
;
return
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment