<div dir="auto"><div><div class="gmail_quote"><div dir="ltr">On Sat., 20 Oct. 2018, 7:00 am Stanislav Blinov via Digitalmars-d, <<a href="mailto:digitalmars-d@puremagic.com">digitalmars-d@puremagic.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Saturday, 20 October 2018 at 02:09:56 UTC, Dominikus Dittes <br>
Scherkl wrote:<br>
> On Saturday, 20 October 2018 at 00:46:36 UTC, Nicholas Wilson <br>
> wrote:<br>
>> Mutable = value may change<br>
>> const = I will not change the value<br>
>> immutable = the value will not change<br>
>><br>
>> unshared = I (well the current thread) owns the reference<br>
>> shared = reference not owned, no unordered access, no <br>
>> (unordered) writes<br>
>> threadsafe = ???<br>
> unshared = the current thread owns the reference<br>
> threadsafe = I guarantee no race conditions or deadlocks will <br>
> occur<br>
> shared = every thread may have references<br>
<br>
Exactly, "thredsafe" in nothing more than a contract between <br>
programmers.<br>
When you have "const" data, it is trivial for the compiler to <br>
enforce that: it just doesn't allow you to mutate it. But the <br>
compiler cannot reason about whether your logic is "threadsafe" <br>
or not, there can be no static enforcement of "thread-safety". It <br>
only holds as an implicit contract between programmers: the <br>
authors of data and functions, and the users of that data and <br>
functions, i.e. the API and the callers.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Only at the level of the trusted functions.</div><div dir="auto">It is *very* easy to write a correct Atomic implementation. Queues and stuff are well understood and have great reference implementations. If you don't write @trusted functions (most wouldn't!), then you can't mess up.</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>