File tree Expand file tree Collapse file tree 1 file changed +14
-15
lines changed Expand file tree Collapse file tree 1 file changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -9,8 +9,7 @@ module GC
9
9
10
10
using .. C: C
11
11
12
- const QUEUE = C. PyPtr[]
13
- const QUEUE_LOCK = Threads. SpinLock ()
12
+ const QUEUE = (; items = C. PyPtr[], lock = Threads. SpinLock ())
14
13
const HOOK = WeakRef ()
15
14
16
15
"""
@@ -56,28 +55,28 @@ function gc()
56
55
end
57
56
58
57
function unsafe_free_queue ()
59
- lock (QUEUE_LOCK )
60
- for ptr in QUEUE
58
+ lock (QUEUE . lock )
59
+ for ptr in QUEUE. items
61
60
if ptr != C. PyNULL
62
61
C. Py_DecRef (ptr)
63
62
end
64
63
end
65
- empty! (QUEUE)
66
- unlock (QUEUE_LOCK )
64
+ empty! (QUEUE. items )
65
+ unlock (QUEUE . lock )
67
66
nothing
68
67
end
69
68
70
69
function enqueue (ptr:: C.PyPtr )
71
70
if ptr != C. PyNULL && C. CTX. is_initialized
72
71
if C. PyGILState_Check () == 1
73
72
C. Py_DecRef (ptr)
74
- if ! isempty (QUEUE)
73
+ if ! isempty (QUEUE. items )
75
74
unsafe_free_queue ()
76
75
end
77
76
else
78
- lock (QUEUE_LOCK )
79
- push! (QUEUE, ptr)
80
- unlock (QUEUE_LOCK )
77
+ lock (QUEUE . lock )
78
+ push! (QUEUE. items , ptr)
79
+ unlock (QUEUE . lock )
81
80
end
82
81
end
83
82
nothing
@@ -91,13 +90,13 @@ function enqueue_all(ptrs)
91
90
C. Py_DecRef (ptr)
92
91
end
93
92
end
94
- if ! isempty (QUEUE)
93
+ if ! isempty (QUEUE. items )
95
94
unsafe_free_queue ()
96
95
end
97
96
else
98
- lock (QUEUE_LOCK )
99
- append! (QUEUE, ptrs)
100
- unlock (QUEUE_LOCK )
97
+ lock (QUEUE . lock )
98
+ append! (QUEUE. items , ptrs)
99
+ unlock (QUEUE . lock )
101
100
end
102
101
end
103
102
nothing
122
121
function _gchook_finalizer (x)
123
122
if C. CTX. is_initialized
124
123
finalizer (_gchook_finalizer, x)
125
- if ! isempty (QUEUE) && C. PyGILState_Check () == 1
124
+ if ! isempty (QUEUE. items ) && C. PyGILState_Check () == 1
126
125
unsafe_free_queue ()
127
126
end
128
127
end
You can’t perform that action at this time.
0 commit comments