Concept proposal: Safely catching error

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 8 09:55:37 PDT 2017


On 6/8/17 11:19 AM, Stanislav Blinov wrote:
> On Thursday, 8 June 2017 at 14:13:53 UTC, Steven Schveighoffer wrote:
>
>> void foo(Mutex m, Data d) pure
>> {
>>    synchronized(m)
>>    {
>>        // ... manipulate d
>>    } // no guarantee m gets unlocked
>> }
>>
>
> Isn't synchronized(m) not nothrow?

You're right, it isn't. I actually didn't know that. Also forgot to make 
my function nothrow. Fixed:

void foo(Mutex m, Data d) pure nothrow
{
    try
    {
       synchronized(m)
       {
          // .. manipulate d
       }
    }
    catch(Exception)
    {
    }
}

-Steve


More information about the Digitalmars-d mailing list