Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
ca2eb6f6
Commit
ca2eb6f6
authored
Jun 07, 2019
by
gsamain
Committed by
Xavier Thompson
Aug 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make with lock statement use the recursive & upgrade capabilities of CyObject lock
parent
02f3a677
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
13 deletions
+7
-13
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+7
-13
No files found.
Cython/Compiler/Nodes.py
View file @
ca2eb6f6
...
...
@@ -8507,25 +8507,19 @@ class LockCypclassNode(StatNode):
def
generate_execution_code
(
self
,
code
):
self
.
obj
.
generate_evaluation_code
(
code
)
# We must unlock if it's a 'with unlocked' statement,
# or if we're changing lock type.
if
self
.
was_rlocked
or
self
.
was_wlocked
:
code
.
putln
(
"Cy_UNLOCK(%s);"
%
self
.
obj
.
result
())
#
Then, lock accordingly
if
self
.
state
==
"rlocked"
:
code
.
putln
(
"Cy_RLOCK(%s);"
%
self
.
obj
.
result
())
elif
self
.
state
==
"wlocked"
:
code
.
putln
(
"Cy_WLOCK(%s);"
%
self
.
obj
.
result
()
)
#
As we're relying on a recursive and upgradable lock,
# we don't need to care about things like unlocking a read lock
# before taking a write lock, so the code is quite brutal here.
lock_code
=
"Cy_%s(%s);"
%
(
self
.
state
[:
-
2
].
upper
(),
self
.
obj
.
result
())
code
.
putln
(
lock_code
)
self
.
body
.
generate_execution_code
(
code
)
# We must unlock if we held a lock previously
# We must unlock if we held a lock previously
, and relock if we unlocked.
if
self
.
state
!=
"unlocked"
:
code
.
putln
(
"Cy_UNLOCK(%s);"
%
self
.
obj
.
result
())
# Then, relock if needed
if
self
.
was_rlocked
:
elif
self
.
was_rlocked
:
code
.
putln
(
"Cy_RLOCK(%s);"
%
self
.
obj
.
result
())
elif
self
.
was_wlocked
:
code
.
putln
(
"Cy_WLOCK(%s);"
%
self
.
obj
.
result
())
...
...
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