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
8f09af4d
Commit
8f09af4d
authored
Jun 18, 2021
by
Julien Jerphanion
Committed by
Xavier Thompson
Sep 17, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove logging on contention
This also remove the associated mutex from the CyLock class.
parent
32727915
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
97 deletions
+0
-97
Cython/Utility/CyObjects.cpp
Cython/Utility/CyObjects.cpp
+0
-97
No files found.
Cython/Utility/CyObjects.cpp
View file @
8f09af4d
...
@@ -19,8 +19,6 @@
...
@@ -19,8 +19,6 @@
#define CyObject_CONTENDING_WRITER_FLAG (1 << 0)
#define CyObject_CONTENDING_WRITER_FLAG (1 << 0)
#define CyObject_CONTENDING_READER_FLAG (1 << 1)
#define CyObject_CONTENDING_READER_FLAG (1 << 1)
#define CyObject_RAISE_ON_CONTENTION 0
#include <atomic>
#include <atomic>
#include <pthread.h>
#include <pthread.h>
...
@@ -37,7 +35,6 @@
...
@@ -37,7 +35,6 @@
#include <type_traits>
#include <type_traits>
class
CyLock
{
class
CyLock
{
static
pthread_mutex_t
log_guard
;
protected:
protected:
pthread_mutex_t
guard
;
pthread_mutex_t
guard
;
pthread_cond_t
readers_have_left
;
pthread_cond_t
readers_have_left
;
...
@@ -67,9 +64,6 @@
...
@@ -67,9 +64,6 @@
int
tryrlock
();
int
tryrlock
();
int
trywlock
();
int
trywlock
();
};
};
#if CyObject_RAISE_ON_CONTENTION == 0
pthread_mutex_t
CyLock
::
log_guard
=
PTHREAD_MUTEX_INITIALIZER
;
#endif
struct
CyPyObject
{
struct
CyPyObject
{
PyObject_HEAD
PyObject_HEAD
...
@@ -724,37 +718,6 @@ void CyLock::rlock(const char *context) {
...
@@ -724,37 +718,6 @@ void CyLock::rlock(const char *context) {
pthread_mutex_lock
(
&
this
->
guard
);
pthread_mutex_lock
(
&
this
->
guard
);
if
(
this
->
write_count
>
0
)
{
#if CyObject_RAISE_ON_CONTENTION
pid_t
owner_id
=
this
->
owner_id
;
std
::
ostringstream
msg
;
msg
<<
"Data Race between [this] reader #"
<<
caller_id
<<
" and [other] writer #"
<<
owner_id
<<
" on lock "
<<
this
;
if
(
context
!=
NULL
)
{
msg
<<
std
::
endl
<<
"In [this] context: "
<<
context
;
}
if
(
this
->
owner_context
!=
NULL
)
{
msg
<<
std
::
endl
<<
"In [other] context: "
<<
this
->
owner_context
;
}
throw
std
::
runtime_error
(
msg
.
str
());
#else
pid_t
owner_id
=
this
->
owner_id
;
pthread_mutex_lock
(
&
(
CyLock
::
log_guard
));
std
::
cerr
<<
"Data Race between [this] reader #"
<<
caller_id
<<
" and [other] writer #"
<<
owner_id
<<
" on lock "
<<
this
<<
std
::
endl
;
if
(
context
!=
NULL
)
{
std
::
cerr
<<
"In [this] context: "
<<
context
<<
std
::
endl
;
}
if
(
this
->
owner_context
!=
NULL
)
{
std
::
cerr
<<
"In [other] context: "
<<
this
->
owner_context
<<
std
::
endl
;
}
pthread_mutex_unlock
(
&
(
CyLock
::
log_guard
));
#endif
}
while
(
this
->
write_count
>
0
)
{
while
(
this
->
write_count
>
0
)
{
pthread_cond_wait
(
&
this
->
writer_has_left
,
&
this
->
guard
);
pthread_cond_wait
(
&
this
->
writer_has_left
,
&
this
->
guard
);
}
}
...
@@ -824,70 +787,10 @@ void CyLock::wlock(const char *context) {
...
@@ -824,70 +787,10 @@ void CyLock::wlock(const char *context) {
// Since we use a reader-preferring approach, we wait first for all readers to leave, and then all writers.
// Since we use a reader-preferring approach, we wait first for all readers to leave, and then all writers.
// The other way around could result in several writers acquiring the lock.
// The other way around could result in several writers acquiring the lock.
if
(
this
->
readers_nb
>
0
)
{
#if CyObject_RAISE_ON_CONTENTION
pid_t
owner_id
=
this
->
owner_id
;
std
::
ostringstream
msg
;
msg
<<
"Data Race between [this] writer #"
<<
caller_id
<<
" and [other] reader #"
<<
owner_id
<<
" on lock "
<<
this
;
if
(
context
!=
NULL
)
{
msg
<<
std
::
endl
<<
"In [this] context: "
<<
context
;
}
if
(
this
->
owner_context
!=
NULL
)
{
msg
<<
std
::
endl
<<
"In [other] context: "
<<
this
->
owner_context
;
}
throw
std
::
runtime_error
(
msg
.
str
());
#else
pthread_mutex_lock
(
&
(
CyLock
::
log_guard
));
std
::
cerr
<<
"Data Race between [this] writer #"
<<
caller_id
<<
" and [other] reader #"
<<
owner_id
<<
" on lock "
<<
this
<<
std
::
endl
;
if
(
context
!=
NULL
)
{
std
::
cerr
<<
"In [this] context: "
<<
context
<<
std
::
endl
;
}
if
(
this
->
owner_context
!=
NULL
)
{
std
::
cerr
<<
"In [other] context: "
<<
this
->
owner_context
<<
std
::
endl
;
}
pthread_mutex_unlock
(
&
(
CyLock
::
log_guard
));
#endif
}
while
(
this
->
readers_nb
>
0
)
{
while
(
this
->
readers_nb
>
0
)
{
pthread_cond_wait
(
&
this
->
readers_have_left
,
&
this
->
guard
);
pthread_cond_wait
(
&
this
->
readers_have_left
,
&
this
->
guard
);
}
}
if
(
this
->
write_count
>
0
)
{
#if CyObject_RAISE_ON_CONTENTION
pid_t
owner_id
=
this
->
owner_id
;
std
::
ostringstream
msg
;
msg
<<
"Data Race between [this] writer #"
<<
caller_id
<<
" and [other] writer #"
<<
owner_id
<<
" on lock "
<<
this
;
if
(
context
!=
NULL
)
{
msg
<<
std
::
endl
<<
"In [this] context: "
<<
context
;
}
if
(
this
->
owner_context
!=
NULL
)
{
msg
<<
std
::
endl
<<
"In [other] context: "
<<
this
->
owner_context
;
}
throw
std
::
runtime_error
(
msg
.
str
());
#else
pthread_mutex_lock
(
&
(
CyLock
::
log_guard
));
std
::
cerr
<<
"Data Race between [this] writer #"
<<
caller_id
<<
" and [other] writer #"
<<
owner_id
<<
" on lock "
<<
this
<<
std
::
endl
;
if
(
context
!=
NULL
)
{
std
::
cerr
<<
"In [this] context: "
<<
context
<<
std
::
endl
;
}
if
(
this
->
owner_context
!=
NULL
)
{
std
::
cerr
<<
"In [other] context: "
<<
this
->
owner_context
<<
std
::
endl
;
}
pthread_mutex_unlock
(
&
(
CyLock
::
log_guard
));
#endif
}
while
(
this
->
write_count
>
0
)
{
while
(
this
->
write_count
>
0
)
{
pthread_cond_wait
(
&
this
->
writer_has_left
,
&
this
->
guard
);
pthread_cond_wait
(
&
this
->
writer_has_left
,
&
this
->
guard
);
}
}
...
...
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