Skip to content

Add variant of Py_BEGIN_CRITICAL_SECTION that accepts a NULL argument #115432

@colesbury

Description

@colesbury

Feature or enhancement

We should add a variant of Py_BEGIN_CRITICAL_SECTION / Py_END_CRITICAL_SECTION that accepts a possibly NULL object. If the passed object is NULL then nothing is locked or unlocked. Otherwise, it behaves like Py_BEGIN_CRITICAL_SECTION.

For example:

PyObject *object = maybe ? real_object : NULL;
Py_XBEGIN_CRITICAL_SECTION(object);
...
Py_XEND_CRITICAL_SECTION();

This will be useful in making set thread-safe. There are a number of functions that take an optional iterable that may be NULL. We want to lock it in the cases where it's not NULL.

I don't think we will need a version of Py_BEGIN_CRITICAL_SECTION2 that accepts optionally NULL arguments.

Linked PRs

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy