Date: Sun, 30 Apr 2023 12:52:51 +0100
Sorry for my ignorance here but I'm struggling to imagine how what you call
the first ever thread can terminate without the program terminating.
Surely if the "main()" thread terminates it has to leave main() and isn't
that the beginning of the end of the program?
On Sun, 30 Apr 2023, 11:38 Frederick Virchanza Gotham via Std-Proposals, <
std-proposals_at_[hidden]> wrote:
> A computer program starts out as just one thread. It can spawn a
> second thread and a third thread. Then the first thread can terminate,
> leaving the second and third to continue.
>
> When we say 'the main thread', 99% of the time we are talking about
> the very first thread that the program started. In rare cases, if the
> first thread has terminated, we might refer to the second thread as
> 'the main thread'. Or if the second has also terminated, maybe we'll
> call the third thread the 'main thread'.
>
> I want to use the terminology 'first_ever' to refer to the first
> thread that constructed the global objects and entered the function
> 'main'.
>
> Here's what C++ programmers are currently doing to get the ID of the
> first thread:
>
> std::thread::id g_id_1st{};
>
> int main(void)
> {
> g_id_1st = std::this_thread::get_id();
> }
>
> And then somewhere else:
>
> if ( std::this_thread::get_id() == g_id_1st )
> {
> std::cout << "main thread\n";
> }
>
> How about we make this easier and more convenient by providing:
>
> namespace std {
> class thread {
> static std::thread::id first_ever(void);
> };
> }
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
the first ever thread can terminate without the program terminating.
Surely if the "main()" thread terminates it has to leave main() and isn't
that the beginning of the end of the program?
On Sun, 30 Apr 2023, 11:38 Frederick Virchanza Gotham via Std-Proposals, <
std-proposals_at_[hidden]> wrote:
> A computer program starts out as just one thread. It can spawn a
> second thread and a third thread. Then the first thread can terminate,
> leaving the second and third to continue.
>
> When we say 'the main thread', 99% of the time we are talking about
> the very first thread that the program started. In rare cases, if the
> first thread has terminated, we might refer to the second thread as
> 'the main thread'. Or if the second has also terminated, maybe we'll
> call the third thread the 'main thread'.
>
> I want to use the terminology 'first_ever' to refer to the first
> thread that constructed the global objects and entered the function
> 'main'.
>
> Here's what C++ programmers are currently doing to get the ID of the
> first thread:
>
> std::thread::id g_id_1st{};
>
> int main(void)
> {
> g_id_1st = std::this_thread::get_id();
> }
>
> And then somewhere else:
>
> if ( std::this_thread::get_id() == g_id_1st )
> {
> std::cout << "main thread\n";
> }
>
> How about we make this easier and more convenient by providing:
>
> namespace std {
> class thread {
> static std::thread::id first_ever(void);
> };
> }
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2023-04-30 11:53:01