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
ddbf3004
Commit
ddbf3004
authored
Aug 13, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve implementation of cypclass atomic reference counting
parent
c1b544f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
Cython/Utility/CyObjects.cpp
Cython/Utility/CyObjects.cpp
+7
-3
No files found.
Cython/Utility/CyObjects.cpp
View file @
ddbf3004
...
...
@@ -554,15 +554,19 @@ void LogLock::wlock() {
pthread_mutex_unlock
(
&
this
->
guard
);
}
/*
* Atomic counter increment and decrement implementation based on
* @source: https://www.boost.org/doc/libs/1_73_0/doc/html/atomic/usage_examples.html
*/
void
CyObject
::
CyObject_INCREF
()
{
atomic_fetch_add
(
&
(
this
->
nogil_ob_refcnt
),
1
);
this
->
nogil_ob_refcnt
.
fetch_add
(
1
,
std
::
memory_order_relaxed
);
}
int
CyObject
::
CyObject_DECREF
()
{
if
(
atomic_fetch_sub
(
&
(
this
->
nogil_ob_refcnt
),
1
)
==
1
)
{
if
(
this
->
nogil_ob_refcnt
.
fetch_sub
(
1
,
std
::
memory_order_release
)
==
1
)
{
std
::
atomic_thread_fence
(
std
::
memory_order_acquire
);
delete
this
;
return
1
;
}
...
...
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