@@ -20,23 +20,23 @@ extern "C" {
20
20
// transitions between "attached" and "detached" on its own PyThreadState.
21
21
//
22
22
// The "suspended" state is used to implement stop-the-world pauses, such as
23
- // for cyclic garbage collection. It is only used in `--disable-gil` builds. It
24
- // is similar to the "detached" state, but only the thread performing a
25
- // stop- the-world pause may transition a thread from the "suspended" state back
26
- // to the "detached" state. A thread trying to "attach" from the "suspended"
27
- // state will block until it is transitioned back to "detached" when the
28
- // stop- the-world pause is complete .
23
+ // for cyclic garbage collection. It is only used in `--disable-gil` builds.
24
+ // The "suspended" state is similar to the "detached" state in that in both
25
+ // states the thread is not allowed to call most Python APIs. However, unlike
26
+ // the "detached" state, a thread may not transition itself out from the
27
+ // "suspended" state. Only the thread performing a stop-the-world pause may
28
+ // transition a thread from the "suspended" state back to the "detached" state .
29
29
//
30
30
// State transition diagram:
31
31
//
32
32
// (bound thread) (stop-the-world thread)
33
33
// [attached] <-> [detached] <-> [suspended]
34
- // + ^
35
- // +----------------------------- ---------------------------+
34
+ // | ^
35
+ // +----------------------------> ---------------------------+
36
36
// (bound thread)
37
37
//
38
- // See `_PyThreadState_Attach()`, `_PyThreadState_Detach()`, and
39
- // `_PyThreadState_Suspend()` .
38
+ // The (bound thread) and (stop-the-world thread) labels indicate which thread
39
+ // is allowed to perform the transition .
40
40
#define _Py_THREAD_DETACHED 0
41
41
#define _Py_THREAD_ATTACHED 1
42
42
#define _Py_THREAD_SUSPENDED 2
@@ -153,10 +153,9 @@ extern void _PyThreadState_Detach(PyThreadState *tstate);
153
153
// Detaches the current thread to the "suspended" state if a stop-the-world
154
154
// pause is in progress.
155
155
//
156
- // If there is no stop-the-world pause in progress, then this function is
157
- // a no-op. Returns one if the thread was switched to the "suspended" state and
158
- // zero otherwise.
159
- extern int _PyThreadState_Suspend (PyThreadState * tstate );
156
+ // If there is no stop-the-world pause in progress, then the thread switches
157
+ // to the "detached" state.
158
+ extern void _PyThreadState_Suspend (PyThreadState * tstate );
160
159
161
160
// Perform a stop-the-world pause for all threads in the all interpreters.
162
161
//
0 commit comments