Deprecate synchronized classes please!
Loara
loara at noreply.com
Tue Sep 6 11:16:19 UTC 2022
On Tuesday, 6 September 2022 at 10:52:13 UTC, IGotD- wrote:
> I'm not sure you mean with "send".
https://dlang.org/phobos/std_concurrency.html#.send
This is the standard method in D to send data to other threads.
Documentation says that you can't send unshared indirections,
even if they're synchronized classes.
>> Also in a `synchronized` class each member becomes `shared`,
>> but this will force you to use atomic operation even if you
>> have exclusive access to data variables. All the stuff around
>> `synchronized` seems poorly designed only as a copy of Java's
>> synchronization and later abandoned.
>
> If all members becomes atomic inside a synchronized class, then
> it's a design error. The whole point of a synchronized class is
> that the members should be normal variables and not atomics.
This is the reason behind error message I've posted. Currently
synchronized classes exists only as a mirror of Java's
synchronization mechanism, but without a well integration with D
ecosystem. Maybe we should rethink entirely `synchronized` inside
D.
More information about the Digitalmars-d
mailing list