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
Xavier Thompson
cython
Commits
961865dc
Commit
961865dc
authored
Nov 09, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove context string argument from cypclass lock implementation
parent
00ba2251
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
47 deletions
+22
-47
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-14
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+2
-13
Cython/Utility/CyObjects.cpp
Cython/Utility/CyObjects.cpp
+18
-20
No files found.
Cython/Compiler/ExprNodes.py
View file @
961865dc
...
@@ -14197,18 +14197,6 @@ class CoerceToLockedNode(CoercionNode):
...
@@ -14197,18 +14197,6 @@ class CoerceToLockedNode(CoercionNode):
return
self
.
arg
.
may_be_none
()
return
self
.
arg
.
may_be_none
()
def
generate_result_code
(
self
,
code
):
def
generate_result_code
(
self
,
code
):
#XXX Code duplicated from Nodes.LockCypclassNode.
if
self
.
arg
.
pos
:
source_descr
,
lineno
,
colno
=
self
.
arg
.
pos
source_str
=
source_descr
.
get_description
()
source_lines
=
source_descr
.
get_lines
()
line_str
=
source_lines
[
lineno
-
1
]
col_str
=
"%s%s"
%
(
' '
*
colno
,
'^'
)
context
=
"%s:%d:%d
\
n
%s%s"
%
(
source_str
,
lineno
,
colno
,
line_str
,
col_str
)
context
=
code
.
get_string_const
(
StringEncoding
.
EncodedString
(
context
))
else
:
context
=
"NULL"
# Create a scope to use scope bound resource management (RAII).
# Create a scope to use scope bound resource management (RAII).
code
.
putln
(
"{"
)
code
.
putln
(
"{"
)
...
@@ -14216,9 +14204,9 @@ class CoerceToLockedNode(CoercionNode):
...
@@ -14216,9 +14204,9 @@ class CoerceToLockedNode(CoercionNode):
# a prefix is enough to prevent name collisions.
# a prefix is enough to prevent name collisions.
guard_code
=
"%sguard"
%
Naming
.
cypclass_lock_guard_prefix
guard_code
=
"%sguard"
%
Naming
.
cypclass_lock_guard_prefix
if
self
.
rlock_only
:
if
self
.
rlock_only
:
code
.
putln
(
"Cy_rlock_guard %s(%s
, %s);"
%
(
guard_code
,
self
.
result
(),
context
))
code
.
putln
(
"Cy_rlock_guard %s(%s
);"
%
(
guard_code
,
self
.
result
()
))
else
:
else
:
code
.
putln
(
"Cy_wlock_guard %s(%s
, %s);"
%
(
guard_code
,
self
.
result
(),
context
))
code
.
putln
(
"Cy_wlock_guard %s(%s
);"
%
(
guard_code
,
self
.
result
()
))
def
generate_disposal_code
(
self
,
code
):
def
generate_disposal_code
(
self
,
code
):
# Close the scope to release the lock.
# Close the scope to release the lock.
...
...
Cython/Compiler/Nodes.py
View file @
961865dc
...
@@ -8612,26 +8612,15 @@ class LockCypclassNode(StatNode):
...
@@ -8612,26 +8612,15 @@ 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
)
if
self
.
obj
.
pos
:
source_descr
,
lineno
,
colno
=
self
.
obj
.
pos
source_str
=
source_descr
.
get_description
()
source_lines
=
source_descr
.
get_lines
()
line_str
=
source_lines
[
lineno
-
1
]
col_str
=
"%s%s"
%
(
' '
*
colno
,
'^'
)
context
=
"%s:%d:%d
\
n
%s%s"
%
(
source_str
,
lineno
,
colno
,
line_str
,
col_str
)
context
=
code
.
get_string_const
(
EncodedString
(
context
))
else
:
context
=
"NULL"
# Create a scope to use scope bound resource management (RAII).
# Create a scope to use scope bound resource management (RAII).
code
.
putln
(
"{"
)
code
.
putln
(
"{"
)
# Each lock guard has its onw scope, so a prefix is enough to prevent name collisions
# Each lock guard has its onw scope, so a prefix is enough to prevent name collisions
guard_code
=
"%sguard"
%
Naming
.
cypclass_lock_guard_prefix
guard_code
=
"%sguard"
%
Naming
.
cypclass_lock_guard_prefix
if
self
.
state
==
"rlocked"
:
if
self
.
state
==
"rlocked"
:
code
.
putln
(
"Cy_rlock_guard %s(%s
, %s);"
%
(
guard_code
,
self
.
obj
.
result
(),
context
))
code
.
putln
(
"Cy_rlock_guard %s(%s
);"
%
(
guard_code
,
self
.
obj
.
result
()
))
elif
self
.
state
==
"wlocked"
:
elif
self
.
state
==
"wlocked"
:
code
.
putln
(
"Cy_wlock_guard %s(%s
,%s);"
%
(
guard_code
,
self
.
obj
.
result
(),
context
))
code
.
putln
(
"Cy_wlock_guard %s(%s
);"
%
(
guard_code
,
self
.
obj
.
result
()
))
self
.
body
.
generate_execution_code
(
code
)
self
.
body
.
generate_execution_code
(
code
)
...
...
Cython/Utility/CyObjects.cpp
View file @
961865dc
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
_readers
=
0
;
_readers
=
0
;
}
}
void
rlock
(
const
char
*
context
)
{
void
rlock
()
{
int
retry
=
0
;
int
retry
=
0
;
while
(
true
)
{
while
(
true
)
{
uint32_t
prev_readers
=
_readers
;
uint32_t
prev_readers
=
_readers
;
...
@@ -95,7 +95,7 @@
...
@@ -95,7 +95,7 @@
}
}
}
}
void
wlock
(
const
char
*
context
)
{
void
wlock
()
{
int
retry
=
0
;
int
retry
=
0
;
while
(
true
)
{
while
(
true
)
{
uint32_t
prev_readers
=
_readers
;
uint32_t
prev_readers
=
_readers
;
...
@@ -144,8 +144,8 @@
...
@@ -144,8 +144,8 @@
void
CyObject_INCREF
()
const
;
void
CyObject_INCREF
()
const
;
int
CyObject_DECREF
()
const
;
int
CyObject_DECREF
()
const
;
int
CyObject_GETREF
()
const
;
int
CyObject_GETREF
()
const
;
void
CyObject_RLOCK
(
const
char
*
context
)
const
;
void
CyObject_RLOCK
()
const
;
void
CyObject_WLOCK
(
const
char
*
context
)
const
;
void
CyObject_WLOCK
()
const
;
void
CyObject_UNRLOCK
()
const
;
void
CyObject_UNRLOCK
()
const
;
void
CyObject_UNWLOCK
()
const
;
void
CyObject_UNWLOCK
()
const
;
int
CyObject_TRYRLOCK
()
const
;
int
CyObject_TRYRLOCK
()
const
;
...
@@ -343,9 +343,9 @@
...
@@ -343,9 +343,9 @@
class
Cy_rlock_guard
{
class
Cy_rlock_guard
{
const
CyObject
*
o
;
const
CyObject
*
o
;
public:
public:
Cy_rlock_guard
(
const
CyObject
*
o
,
const
char
*
context
)
:
o
(
o
)
{
Cy_rlock_guard
(
const
CyObject
*
o
)
:
o
(
o
)
{
if
(
o
!=
NULL
)
{
if
(
o
!=
NULL
)
{
o
->
CyObject_RLOCK
(
context
);
o
->
CyObject_RLOCK
();
}
}
else
{
else
{
fprintf
(
stderr
,
"ERROR: trying to rlock NULL !
\n
"
);
fprintf
(
stderr
,
"ERROR: trying to rlock NULL !
\n
"
);
...
@@ -364,9 +364,9 @@
...
@@ -364,9 +364,9 @@
class
Cy_wlock_guard
{
class
Cy_wlock_guard
{
const
CyObject
*
o
;
const
CyObject
*
o
;
public:
public:
Cy_wlock_guard
(
const
CyObject
*
o
,
const
char
*
context
)
:
o
(
o
)
{
Cy_wlock_guard
(
const
CyObject
*
o
)
:
o
(
o
)
{
if
(
o
!=
NULL
)
{
if
(
o
!=
NULL
)
{
o
->
CyObject_WLOCK
(
context
);
o
->
CyObject_WLOCK
();
}
}
else
{
else
{
fprintf
(
stderr
,
"ERROR: trying to wlock NULL !
\n
"
);
fprintf
(
stderr
,
"ERROR: trying to wlock NULL !
\n
"
);
...
@@ -449,18 +449,18 @@
...
@@ -449,18 +449,18 @@
return
ob
->
CyObject_GETREF
();
return
ob
->
CyObject_GETREF
();
}
}
static
inline
void
_Cy_RLOCK
(
const
CyObject
*
ob
,
const
char
*
context
)
{
static
inline
void
_Cy_RLOCK
(
const
CyObject
*
ob
)
{
if
(
ob
!=
NULL
)
{
if
(
ob
!=
NULL
)
{
ob
->
CyObject_RLOCK
(
context
);
ob
->
CyObject_RLOCK
();
}
}
else
{
else
{
fprintf
(
stderr
,
"ERROR: trying to read lock NULL !
\n
"
);
fprintf
(
stderr
,
"ERROR: trying to read lock NULL !
\n
"
);
}
}
}
}
static
inline
void
_Cy_WLOCK
(
const
CyObject
*
ob
,
const
char
*
context
)
{
static
inline
void
_Cy_WLOCK
(
const
CyObject
*
ob
)
{
if
(
ob
!=
NULL
)
{
if
(
ob
!=
NULL
)
{
ob
->
CyObject_WLOCK
(
context
);
ob
->
CyObject_WLOCK
();
}
}
else
{
else
{
fprintf
(
stderr
,
"ERROR: trying to write lock NULL !
\n
"
);
fprintf
(
stderr
,
"ERROR: trying to write lock NULL !
\n
"
);
...
@@ -573,10 +573,8 @@
...
@@ -573,10 +573,8 @@
#define Cy_XGOTREF(ob)
#define Cy_XGOTREF(ob)
#define Cy_GIVEREF(ob)
#define Cy_GIVEREF(ob)
#define Cy_XGIVEREF(ob)
#define Cy_XGIVEREF(ob)
#define Cy_RLOCK(ob) _Cy_RLOCK(ob, NULL)
#define Cy_RLOCK(ob) _Cy_RLOCK(ob)
#define Cy_WLOCK(ob) _Cy_WLOCK(ob, NULL)
#define Cy_WLOCK(ob) _Cy_WLOCK(ob)
#define Cy_RLOCK_CONTEXT(ob, context) _Cy_RLOCK(ob, context)
#define Cy_WLOCK_CONTEXT(ob, context) _Cy_WLOCK(ob, context)
#define Cy_UNRLOCK(ob) _Cy_UNRLOCK(ob)
#define Cy_UNRLOCK(ob) _Cy_UNRLOCK(ob)
#define Cy_UNWLOCK(ob) _Cy_UNWLOCK(ob)
#define Cy_UNWLOCK(ob) _Cy_UNWLOCK(ob)
#define Cy_TRYRLOCK(ob) _Cy_TRYRLOCK(ob)
#define Cy_TRYRLOCK(ob) _Cy_TRYRLOCK(ob)
...
@@ -621,14 +619,14 @@ int CyObject::CyObject_GETREF() const
...
@@ -621,14 +619,14 @@ int CyObject::CyObject_GETREF() const
return
this
->
nogil_ob_refcnt
;
return
this
->
nogil_ob_refcnt
;
}
}
void
CyObject
::
CyObject_RLOCK
(
const
char
*
context
)
const
void
CyObject
::
CyObject_RLOCK
()
const
{
{
this
->
ob_lock
.
rlock
(
context
);
this
->
ob_lock
.
rlock
();
}
}
void
CyObject
::
CyObject_WLOCK
(
const
char
*
context
)
const
void
CyObject
::
CyObject_WLOCK
()
const
{
{
this
->
ob_lock
.
wlock
(
context
);
this
->
ob_lock
.
wlock
();
}
}
int
CyObject
::
CyObject_TRYRLOCK
()
const
int
CyObject
::
CyObject_TRYRLOCK
()
const
...
...
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