1515#include " TGreenlet.hpp"
1616
1717#include " greenlet_thread_support.hpp"
18- #include " greenlet_cpython_add_pending.hpp"
1918#include " greenlet_compiler_compat.hpp"
2019#include " TGreenletGlobals.cpp"
2120#include " TThreadState.hpp"
@@ -168,47 +167,7 @@ struct ThreadState_DestroyNoGIL
168167 delete state; // Deleting this runs the destructor, DECREFs the main greenlet.
169168 }
170169
171- // ensure this is actually defined.
172- static_assert (GREENLET_BROKEN_PY_ADD_PENDING == 1 || GREENLET_BROKEN_PY_ADD_PENDING == 0 ,
173- " GREENLET_BROKEN_PY_ADD_PENDING not defined correctly." );
174170
175- #if GREENLET_BROKEN_PY_ADD_PENDING
176- static int _push_pending_call (struct _pending_calls *pending,
177- int (*func)(void *), void *arg)
178- {
179- int i = pending->last ;
180- int j = (i + 1 ) % NPENDINGCALLS;
181- if (j == pending->first ) {
182- return -1 ; /* Queue full */
183- }
184- pending->calls [i].func = func;
185- pending->calls [i].arg = arg;
186- pending->last = j;
187- return 0 ;
188- }
189-
190- static int AddPendingCall (int (*func)(void *), void *arg)
191- {
192- _PyRuntimeState *runtime = &_PyRuntime;
193- if (!runtime) {
194- // obviously impossible
195- return 0 ;
196- }
197- struct _pending_calls *pending = &runtime->ceval .pending ;
198- if (!pending->lock ) {
199- return 0 ;
200- }
201- int result = 0 ;
202- PyThread_acquire_lock (pending->lock , WAIT_LOCK);
203- if (!pending->finishing ) {
204- result = _push_pending_call (pending, func, arg);
205- }
206- PyThread_release_lock (pending->lock );
207- SIGNAL_PENDING_CALLS (&runtime->ceval );
208- return result;
209- }
210- #else
211- // Python < 3.8 or >= 3.9
212171 static int AddPendingCall (int (*func)(void *), void* arg)
213172 {
214173 // If the interpreter is in the middle of finalizing, we can't add a
@@ -234,7 +193,7 @@ struct ThreadState_DestroyNoGIL
234193 }
235194 return Py_AddPendingCall (func, arg);
236195 }
237- # endif
196+
238197
239198
240199
0 commit comments