@@ -60,24 +60,32 @@ iolock_end() = ccall(:jl_iolock_end, Cvoid, ())
60
60
const uvhandles = IdDict ()
61
61
const preserve_handle_lock = Threads. SpinLock ()
62
62
@nospecializeinfer function preserve_handle (@nospecialize (x))
63
- lock (preserve_handle_lock)
64
- v = get (uvhandles, x, 0 ):: Int
65
- uvhandles[x] = v + 1
66
- unlock (preserve_handle_lock)
63
+ @static if Base. USING_STOCK_GC
64
+ lock (preserve_handle_lock)
65
+ v = get (uvhandles, x, 0 ):: Int
66
+ uvhandles[x] = v + 1
67
+ unlock (preserve_handle_lock)
68
+ else
69
+ Base. increment_tpin_count! (x)
70
+ end
67
71
nothing
68
72
end
69
73
@nospecializeinfer function unpreserve_handle (@nospecialize (x))
70
- lock (preserve_handle_lock)
71
- v = get (uvhandles, x, 0 ):: Int
72
- if v == 0
74
+ @static if Base. USING_STOCK_GC
75
+ lock (preserve_handle_lock)
76
+ v = get (uvhandles, x, 0 ):: Int
77
+ if v == 0
78
+ unlock (preserve_handle_lock)
79
+ error (" unbalanced call to unpreserve_handle for $(typeof (x)) " )
80
+ elseif v == 1
81
+ pop! (uvhandles, x)
82
+ else
83
+ uvhandles[x] = v - 1
84
+ end
73
85
unlock (preserve_handle_lock)
74
- error (" unbalanced call to unpreserve_handle for $(typeof (x)) " )
75
- elseif v == 1
76
- pop! (uvhandles, x)
77
86
else
78
- uvhandles[x] = v - 1
87
+ Base . decrement_tpin_count! (x)
79
88
end
80
- unlock (preserve_handle_lock)
81
89
nothing
82
90
end
83
91
0 commit comments