[Python-Dev] Change definition of Py_END_ALLOW_THREADS?
Mark Hammond
mhammond@skippinet.com.au
Fri, 14 Feb 2003 09:42:53 +1100
> > OTOH, in the code I am patching there already exists "#ifdef
> > __cplusplus" - I am so tempted to add a tiny little extra block
> > define a helper C++ class in the Python sources for managing this.
> > However, if I do that I fear the Spanish Inquisition will look like
> > a stroll in the park <wink>
>
> Cardinal Biggles, get the soft cushions!
:)
> Actually, relying on C++ would be bad, since this might be useful
> outside Windows as well.
Well, I was thinking of:
#ifdef __cplusplus
class PyAutoThreadState {
PyAutoThreadState() {state = PyAutoThreadState_Ensure();}
~PyAutoThreadState() {PyAutoThreadState_Restore(state);}
PyAutoThreadState_State state;
}
#endif
Meaning the C level API is always there, but a C++ compiler on any platform
should allow extension authors to say:
void MyCppFunc(void)
{
PyAutoThreadState state;
}
And the rest happens by magic.
Was-only-half-serious-but-getting-more-so ly,
Mark.