Skip to content

Commit a0bc324

Browse files
committed
Remove code examples from ob_mutex section per review
1 parent 5e1ba4a commit a0bc324

File tree

1 file changed

+1
-22
lines changed

1 file changed

+1
-22
lines changed

Doc/howto/free-threading-extensions.rst

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -410,28 +410,7 @@ that point, a deadlock can occur.
410410
If your extension type needs its own lock, add a separate :c:type:`PyMutex`
411411
field (or another synchronization primitive) to your object struct.
412412
:c:type:`PyMutex` is very lightweight — it is only one byte — so there is
413-
negligible cost to having an additional one::
414-
415-
/* WRONG — do not lock ob_mutex directly */
416-
PyMutex_Lock(&obj->ob_mutex);
417-
...
418-
PyMutex_Unlock(&obj->ob_mutex);
419-
420-
/* RIGHT — use critical sections for ob_mutex */
421-
Py_BEGIN_CRITICAL_SECTION(obj);
422-
...
423-
Py_END_CRITICAL_SECTION();
424-
425-
/* RIGHT — use your own mutex for your own state */
426-
typedef struct {
427-
PyObject_HEAD
428-
PyMutex my_mutex; /* separate lock for extension state */
429-
int my_data;
430-
} MyObject;
431-
432-
PyMutex_Lock(&self->my_mutex);
433-
self->my_data++;
434-
PyMutex_Unlock(&self->my_mutex);
413+
negligible cost to having an additional one.
435414

436415

437416
Building Extensions for the Free-Threaded Build

0 commit comments

Comments
 (0)