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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
f19d0b27
Commit
f19d0b27
authored
Jun 07, 2019
by
gsamain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make with lock statement use the recursive & upgrade capabilities of CyObject lock
parent
56673057
Changes
1
Hide 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 @
f19d0b27
...
@@ -8257,25 +8257,19 @@ class LockCypclassNode(StatNode):
...
@@ -8257,25 +8257,19 @@ class LockCypclassNode(StatNode):
def
generate_execution_code
(
self
,
code
):
def
generate_execution_code
(
self
,
code
):
self
.
obj
.
generate_evaluation_code
(
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
#
As we're relying on a recursive and upgradable lock,
if
self
.
state
==
"rlocked"
:
# we don't need to care about things like unlocking a read lock
code
.
putln
(
"Cy_RLOCK(%s);"
%
self
.
obj
.
result
())
# before taking a write lock, so the code is quite brutal here.
elif
self
.
state
==
"wlocked"
:
lock_code
=
"Cy_%s(%s);"
%
(
self
.
state
[:
-
2
].
upper
(),
self
.
obj
.
result
())
code
.
putln
(
"Cy_WLOCK(%s);"
%
self
.
obj
.
result
()
)
code
.
putln
(
lock_code
)
self
.
body
.
generate_execution_code
(
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"
:
if
self
.
state
!=
"unlocked"
:
code
.
putln
(
"Cy_UNLOCK(%s);"
%
self
.
obj
.
result
())
code
.
putln
(
"Cy_UNLOCK(%s);"
%
self
.
obj
.
result
())
elif
self
.
was_rlocked
:
# Then, relock if needed
if
self
.
was_rlocked
:
code
.
putln
(
"Cy_RLOCK(%s);"
%
self
.
obj
.
result
())
code
.
putln
(
"Cy_RLOCK(%s);"
%
self
.
obj
.
result
())
elif
self
.
was_wlocked
:
elif
self
.
was_wlocked
:
code
.
putln
(
"Cy_WLOCK(%s);"
%
self
.
obj
.
result
())
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