1+ cdef inline void _debug_cb_handles_inc(Loop loop):
2+ if _debug_cb_handles_lock != NULL :
3+ PyThread_acquire_lock(_debug_cb_handles_lock, 1 )
4+ loop._debug_cb_handles_total += 1
5+ loop._debug_cb_handles_count += 1
6+ if _debug_cb_handles_lock != NULL :
7+ PyThread_release_lock(_debug_cb_handles_lock)
8+
9+
10+ cdef inline void _debug_cb_handles_dec(Loop loop):
11+ if _debug_cb_handles_lock != NULL :
12+ PyThread_acquire_lock(_debug_cb_handles_lock, 1 )
13+ loop._debug_cb_handles_count -= 1
14+ if _debug_cb_handles_lock != NULL :
15+ PyThread_release_lock(_debug_cb_handles_lock)
16+
17+
118@cython.no_gc_clear
219@ cython.freelist (DEFAULT_FREELIST_SIZE)
320cdef class Handle:
@@ -9,8 +26,7 @@ cdef class Handle:
926 cdef inline _set_loop(self , Loop loop):
1027 self .loop = loop
1128 if UVLOOP_DEBUG:
12- loop._debug_cb_handles_total += 1
13- loop._debug_cb_handles_count += 1
29+ _debug_cb_handles_inc(loop)
1430 if loop._debug:
1531 self ._source_traceback = extract_stack()
1632
@@ -21,7 +37,7 @@ cdef class Handle:
2137
2238 def __dealloc__ (self ):
2339 if UVLOOP_DEBUG and self .loop is not None :
24- self .loop._debug_cb_handles_count -= 1
40+ _debug_cb_handles_dec( self .loop)
2541 if self .loop is None :
2642 raise RuntimeError (' Handle.loop is None in Handle.__dealloc__' )
2743
0 commit comments