File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ cdef class Handle:
1010 self .loop = loop
1111 if UVLOOP_DEBUG:
1212 loop._debug_cb_handles_total += 1
13- loop._debug_cb_handles_count += 1
13+ system.__atomic_fetch_add(
14+ & loop._debug_cb_handles_count, 1 , system.__ATOMIC_RELAXED)
1415 if loop._debug:
1516 self ._source_traceback = extract_stack()
1617
@@ -21,7 +22,8 @@ cdef class Handle:
2122
2223 def __dealloc__ (self ):
2324 if UVLOOP_DEBUG and self .loop is not None :
24- self .loop._debug_cb_handles_count -= 1
25+ system.__atomic_fetch_sub(
26+ & self .loop._debug_cb_handles_count, 1 , system.__ATOMIC_RELAXED)
2527 if self .loop is None :
2628 raise RuntimeError (' Handle.loop is None in Handle.__dealloc__' )
2729
Original file line number Diff line number Diff line change @@ -94,3 +94,11 @@ cdef extern from "includes/fork_handler.h":
9494 void setForkHandler(OnForkHandler handler)
9595 void resetForkHandler()
9696 void setMainThreadID(uint64_t id )
97+
98+
99+ cdef extern from * nogil:
100+ uint64_t __atomic_fetch_add(uint64_t * ptr, uint64_t val, int memorder)
101+ uint64_t __atomic_fetch_sub(uint64_t * ptr, uint64_t val, int memorder)
102+
103+ cdef enum :
104+ __ATOMIC_RELAXED
You can’t perform that action at this time.
0 commit comments