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: Wed, 29 Nov 2023 10:28:26 +0000
On Tue, Nov 28, 2023 at 8:50 PM Thiago Macieira
>
>
> Read: "I have a bug in my software and I want to work around it".
>
> You should fix the bug instead. Make your thread properly time out and give the
> proper notification that it failed, so the future knows so.


I think it's either a device driver, or the operating system, or the
virtual machine software that's locking up.

I've got Linux running in a virtual machine, with the internet connect
bridged to the host PC, and inside the virtual machine I have an SSH
connection to a remote computer on the internet over which I'm passing
TCP traffic. If the SSH connection dies for a few seconds, I get a
total lock up of the thread.

But of course the details of my project aren't particularly relevant
here on this mailing list -- the principle here is that sometimes,
although rarely, you want to just give up on an object and forget
about destroying it. For now I think I'll just do:

    memset( &obj.value(), 0, sizeof obj.value() ); // not needed
but paranoia is good
    ::new( &obj.value() ) std::future<bool>();

This kind of thing but also be needed for example in embedded systems
if a bus manager locks up.

Received on 2023-11-29 10:28:38