Date: Wed, 11 Dec 2024 21:19:34 +0000
On Wed, 11 Dec 2024, 21:14 Phil Bouchard via Std-Proposals, <
std-proposals_at_[hidden]> wrote:
> Greetings,
>
> Given the following I came to realise there's no way in C++ to check if a
> thread was properly created or not (right after the equivalent C call to
> pthread_create()).
>
What does properly created mean? How can it not be properly created?
If pthread_create returns an error the std:: thread constructor will throw
an exception, so it never gets constructed and you can't call joinable() on
it anyway.
> So I would like to suggest adding such check in joinable() call to do so.
>
> Because under high concurrency a call to C++'s detach() can understandibly
> segfault.
>
How?
std-proposals_at_[hidden]> wrote:
> Greetings,
>
> Given the following I came to realise there's no way in C++ to check if a
> thread was properly created or not (right after the equivalent C call to
> pthread_create()).
>
What does properly created mean? How can it not be properly created?
If pthread_create returns an error the std:: thread constructor will throw
an exception, so it never gets constructed and you can't call joinable() on
it anyway.
> So I would like to suggest adding such check in joinable() call to do so.
>
> Because under high concurrency a call to C++'s detach() can understandibly
> segfault.
>
How?
Received on 2024-12-11 21:20:53