Matt wrote:
But now I'm confused by the idea that you wouldn't want to use the
same code on shared and unshared data.  The usual approach in C or
C++ in dealing with shared data is to first acquire a lock and then
to run code that would have been otherwise safe on the data.  Is
there some way to cast shared to thread local when a local has been
acquired?

Shared data becomes unshared for the duration of a lock on it. The problem with this is:

1. determining that there are no other shared references into that data.

2. determining that the code operating on that data doesn't squirrel away a thread local reference to it.

Currently, Bartosz is working on these problems. There is no solution yet other than using an (unsafe) cast and relying on the user not to screw it up.

Can you imagine two threads trying to sort the same array?
Not at the same time, but yes.

That's why there's no way one would do this with simply shared data. Locks would be needed, too.

Reply via email to