[Issue 19279] New: mutable does not promote to shared
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Oct 1 04:13:20 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=19279
Issue ID: 19279
Summary: mutable does not promote to shared
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: turkeyman at gmail.com
struct Bob
{
void setThing() shared;
}
As I understand, `shared` attribution intends to guarantee that I dun
synchronisation internally.
This method is declared shared, so if I have shared instances, I can
call it... because it must handle thread-safety internally.
void f(ref shared Bob a, ref Bob b)
{
a.setThing(); // I have a shared object, can call shared method
b.setThing(); // ERROR
}
The method is shared, which suggests that it must handle thread-safety. My
instance `b` is NOT shared, that is, it is thread-local.
A method that handles thread-safety doesn't not work when it's only accessed
from a single thread.
mutable -> shared should work the same as mutable -> const... because surely
that's safe?
--
More information about the Digitalmars-d-bugs
mailing list