What To Do About Shared?

dsimcha dsimcha at yahoo.com
Wed Mar 23 10:38:26 PDT 2011


== Quote from Don (nospam at nospam.com)'s article
> Seems to me, that you're making use of some primitive that I'll call a
> 'DivisableArray' -- an array that can be sliced up (into other
> DivisibleArrays), and different DivisableArrays can be sent to different
> threads. You can extract a normal array slice from a DivisibleArray, but
> cannot send that slice to other threads: only DivisibleArrays can do that.
> In debug mode, a DivisibleArray could keep track of how it has been
> sliced, and disallow overlapping slices. The DivisibleArray could even
> ensure that all slices lie on word/paragraph boundaries, thus dealing
> with word tearing.

I'm not sure.  I assume that the implementation would rely on a shared array, plus
casting away shared under the hood when you extract a normal array.  In this case,
you could still have a DivisibleArray aliased to an unshared slice into this
array.  This is not safe IIUC.

If I'm misunderstanding something, please correct me.


More information about the Digitalmars-d mailing list