Ah, but I think you missed the main point of the new patch.
There is a counter incremented and decremented. So, the State is set
only when the first thread enters a guarded section, and then restored
when the final thread leaves the section. There is no per-thread
storage of the previous state anymore, only static variables storing
the "unmodified state" to restore to when the last thread leaves a
guarded section. As long as some thread is in a guarded section,
assertions and stuff is turned off, otherwise, we keep the old ones.
This is similar in some ways to the special version of
Py_BEGIN_ALLOW_THREADS (FILE_BEGIN_ALLOW_THREADS, was it?) used in
fileio.c. |