study: use checkedint as a drop-in replacement of native long

Nathan S. no.public.email at example.com
Wed Mar 24 17:12:42 UTC 2021


On Saturday, 15 August 2020 at 04:28:05 UTC, mw wrote:
>   // 7. atomic won't work
>   core.atomic.atomicOp!"+="(s.sl, lb);
> //core.atomic.atomicOp!"+="(s.sL, cb);  // Error: template 
> instance core.atomic.atomicOp!("+=", Checked!(long, Abort), 
> Checked!(long, Abort)) error instantiating
> //core.atomic.atomicFetchAdd(s.sL, cb);  // Error: template 
> core.atomic.atomicFetchAdd cannot deduce function from argument 
> types !()(shared(Checked!(long, Abort)), Checked!(long, 
> Abort)), candidates are:
> }
> ------------------------------------------------------------------------

I've been taking a crack at fixing some of these issue but I 
think `atomicOp` is incompatible with the premise of `Checked!T`. 
Either the Hook won't have the opportunity to intercept the 
update based on what the result would be or the update won't be 
atomic.

`atomicLoad`, `atomicStore`, and `cas` should be fine though as 
long as there is no Hook state.


More information about the Digitalmars-d mailing list