Very limited shared promotion

Manu turkeyman at gmail.com
Wed Jun 26 01:48:01 UTC 2019


On Mon, Jun 24, 2019 at 12:50 PM Walter Bright via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> On 6/22/2019 4:44 PM, Manu wrote:
> > Not being required to duplicate every threadsafe function is a huge advantage.
> > We went on about this for weeks 6 months ago.
>
> You've suggested that all operations on shared data be done with atomic function
> calls rather than operators. This implies the function bodies should be different.

I don't follow that logic? There may be atomics, but there are also
cast-away-shared patterns that may be used. It's all very situational.
Whatever a shared function does is its own business, I'm interested in
the API from the callers perspective here.

Whatever a shared method does, it simply must be threadsafe. Such a
function is still threadsafe whether there are many threads with a
reference to the shared object, or just one.
A method that performs a threadsafe operation on some object can
safely perform it thread-locally, and we should be able to allow that
assuming the callee does NOT retain a shared reference to the object
beyond the life of the call. We should be able to rely on `scope` to
guarantee references are not retained beyond the life of the function.

This would be extremely useful.


More information about the Digitalmars-d mailing list