File tree 2 files changed +4
-4
lines changed
2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ struct _is {
112
112
/* The thread currently executing in the __main__ module, if any. */
113
113
PyThreadState * main ;
114
114
/* Used in Modules/_threadmodule.c. */
115
- long count ;
115
+ Py_ssize_t count ;
116
116
/* Support for runtime thread stack size tuning.
117
117
A value of 0 means using the platform's default stack size
118
118
or the size specified by the THREAD_STACK_SIZE macro. */
Original file line number Diff line number Diff line change @@ -1244,7 +1244,7 @@ thread_run(void *boot_raw)
1244
1244
1245
1245
_PyThreadState_Bind (tstate );
1246
1246
PyEval_AcquireThread (tstate );
1247
- tstate -> interp -> threads .count ++ ;
1247
+ _Py_atomic_add_ssize ( & tstate -> interp -> threads .count , 1 ) ;
1248
1248
1249
1249
PyObject * res = PyObject_Call (boot -> func , boot -> args , boot -> kwargs );
1250
1250
if (res == NULL ) {
@@ -1262,7 +1262,7 @@ thread_run(void *boot_raw)
1262
1262
1263
1263
thread_bootstate_free (boot , 1 );
1264
1264
1265
- tstate -> interp -> threads .count -- ;
1265
+ _Py_atomic_add_ssize ( & tstate -> interp -> threads .count , -1 ) ;
1266
1266
PyThreadState_Clear (tstate );
1267
1267
_PyThreadState_DeleteCurrent (tstate );
1268
1268
@@ -1539,7 +1539,7 @@ static PyObject *
1539
1539
thread__count (PyObject * self , PyObject * Py_UNUSED (ignored ))
1540
1540
{
1541
1541
PyInterpreterState * interp = _PyInterpreterState_GET ();
1542
- return PyLong_FromLong ( interp -> threads .count );
1542
+ return PyLong_FromSsize_t ( _Py_atomic_load_ssize ( & interp -> threads .count ) );
1543
1543
}
1544
1544
1545
1545
PyDoc_STRVAR (_count_doc ,
You can’t perform that action at this time.
0 commit comments