Is synchronized(...){...} doomed to never be nothrow/@nogc?
Jacob Carlborg via Digitalmars-d
digitalmars-d at puremagic.com
Wed May 11 00:01:43 PDT 2016
On 2016-05-11 03:08, Walter Bright wrote:
> Why does vibe.d throw?
>
> Also, any throwing code can be converted to nothrow with:
>
> try
> {
> ...throwing code...
> }
> catch (Exception e)
> {
> ...
> }
There's code in DWT and Tango as well that throws a SyncException
exception when failing to acquire a lock.
The code in DWT is basically copy pasted from Tango. Since druntime is
derived from Tango I guess we can update the code in DWT and Tango to do
what druntime does now, which is to throw an error instead.
It's still a breaking change.
Although I see now that there is a problem with updating the code in
DWT. In some cases it catches SyncException with some logic based on
that. In one case the try-catch is wrapped in a loop and will continue
to try to acquire the look [1]. In another case it catches SyncException
and triggers an interrupt [2], which I see now is not implemented [3].
Please advise how these two cases should be implemented when a lock will
throw an error instead of exception (since errors should not be caught).
Hmm, maybe I can extend the API. Monitor is not used directly in any of
the cases.
[1]
https://github.com/d-widget-toolkit/org.eclipse.swt.gtk.linux.x86/blob/master/src/org/eclipse/swt/internal/Lock.d#L55
[2]
https://github.com/d-widget-toolkit/org.eclipse.swt.gtk.linux.x86/blob/master/src/org/eclipse/swt/widgets/Synchronizer.d#L192-L198
[3]
https://github.com/d-widget-toolkit/org.eclipse.swt.gtk.linux.x86/blob/master/src/org/eclipse/swt/internal/Compatibility.d#L402-L405
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list