Commit f41520f
Fix stale GVL comments in Coolio_Loop_process_event (#106)
The comments here say the Global VM Lock is not held, and build a whole
explanation on top of that: the event is stashed rather than dispatched
because "we can't rb_funcall() anything" until the GVL comes back.
That stopped being true. cool.io patches ev_run() to release the GVL only
around the blocking backend call (ev.c, rb_thread_call_without_gvl on
ev_backend_poll); libev invokes the events it collected after that call has
returned, so this function runs with the GVL held.
The code was never unsafe -- xrealloc() of the event buffer and the watcher
lookup both happen under the GVL -- but a reader who believes the comment
would conclude the opposite, and would be wary of touching anything here.
Describe what the code actually does instead: events are stashed and
dispatched by Coolio_Loop_dispatch_events() once ev_loop() returns, and a
watcher detached during that dispatch nils its own stashed entries, which the
dispatch walk skips.
Comments only, no behaviour change.
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>1 parent 557934f commit f41520f
1 file changed
Lines changed: 15 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
114 | | - | |
| 113 | + | |
115 | 114 | | |
116 | 115 | | |
117 | 116 | | |
| |||
126 | 125 | | |
127 | 126 | | |
128 | 127 | | |
129 | | - | |
130 | | - | |
| 128 | + | |
| 129 | + | |
131 | 130 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
154 | | - | |
155 | | - | |
| 153 | + | |
| 154 | + | |
156 | 155 | | |
157 | | - | |
| 156 | + | |
158 | 157 | | |
159 | | - | |
| 158 | + | |
160 | 159 | | |
161 | 160 | | |
162 | 161 | | |
163 | 162 | | |
164 | | - | |
165 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| |||
0 commit comments