C++ Logo

std-proposals

Advanced search

Re: [std-proposals] void std::optional<T>::abandon(void) noexcept

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Tue, 28 Nov 2023 13:22:12 +0000
On Tue, Nov 28, 2023 at 1:16 PM Andrey Semashev wrote:
>
> This would result in UB or resource leak.


When you program in the real world, stuff like this is sometimes
necessary. If you have spawned 6 threads, and if one of them freezes,
you can abandon the frozen thread and just start another one. I would
however keep count of how many threads have been frozen so far, and
when it reaches 12, tell the user that it's time to restart the
program. The user will probably be done using the program before it
climbs to 12.

Or in the case of embedded programming, where you have a class
managing a bus, and if the bus freezes up, you just want to abandon it
and start afresh with a new object to manage the bus.

Received on 2023-11-28 13:22:25