1. Armin Rigo
  2. cpython-withatomic

Commits

Armin Rigo  committed d3eef2c

Reset ts_atomic_counter when a thread exits.

  • Participants
  • Parent commits 1be8e4b
  • Branches stm-thread

Comments (0)

Files changed (1)

File Modules/_threadmodule.c

View file
  • Ignore whitespace
 static PyObject *ThreadError;
 static long nb_threads = 0;
 static PyObject *str_dict;
+static unsigned int ts_atomic_counter = 0;
 
 /* Lock objects */
 
     nb_threads++;
     res = PyEval_CallObjectWithKeywords(
         boot->func, boot->args, boot->keyw);
+    if (ts_atomic_counter > 0) {
+        ts_atomic_counter = 0;
+        _PyEval_SetWithAtomic(NULL);
+    }
     if (res == NULL) {
         if (PyErr_ExceptionMatches(PyExc_SystemExit))
             PyErr_Clear();
 (4kB pages are common; using multiples of 4096 for the stack size is\n\
 the suggested approach in the absence of more specific information).");
 
-static unsigned int ts_atomic_counter = 0;
-
 static PyObject *
 thread_atomic_enter(PyObject *self)
 {