digitalmars.D - synchronized with multiple arguments
- Andrei Alexandrescu (9/9) May 13 2016 A reader reminded me (thanks!) that in TDPL synchronized with multiple
- ZombineDev (8/17) May 13 2016 Here's the relevant code:
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. Is synchronized being lowered to some function calls? Andrei
May 13 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.+1Is 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?
May 13 2016