synchronized with multiple arguments
ZombineDev via Digitalmars-d
digitalmars-d at puremagic.com
Fri May 13 03:42:05 PDT 2016
On Friday, 13 May 2016 at 09:17:06 UTC, Andrei Alexandrescu wrote:
> A reader reminded me (thanks!) that in TDPL synchronized with
> multiple argument does the right thing - locks objects in
> increasing order of address.
>
> So now to everyone's unpleasant surprise, the sample code in
> TDPL compiles and runs, it just has difficult to detect
> problems.
>
> So regardless of the discussion of the comma operator,
> synchronized with multiple arguments should just work.
+1
> Is synchronized being lowered to some function calls?
Here's the relevant code:
https://github.com/dlang/dmd/blob/master/src/statement.d#L4974
IIUC, the code assumes that there is a single object that needs
to be locked. Which is definitely wrong.
BTW, should synchronized (obj) allow calling non-shared methods
of obj inside the block?
More information about the Digitalmars-d
mailing list