Concurrency.

Debdatta debdatta.basu91 at gmail.com
Mon Nov 28 03:48:17 PST 2011


I get it now. Totally. This is like a mechanism to enable shared-correctness. Just like const correctness in c++. :D

This does allow for some nice static runtime checks to ensure that the code is free of races. But I somehow still like the deafult is shared idiom.
To be fair i never use const correctness features in c++ either. :P

In my (limited) experience, involving mostly threading for performance, sharing is the norm.( Take a look at .NET's task parallel library, or
intel's TBB.)

the point i am trying to make is that restricting access to thread specific data is far simpler than keeping track of what is shared. this is
because shared data is usually all over the place when you want to thread for performance. However, thread local data resides in one place( the
thread class mostly).

Look at the example I gave a few posts back:

class MyThread : Thread
{

public:

void run;


private:

//any data i put here can only be seen by the current thread.

}

Keeping this in mind, whats the rationale for no default sharing?

-Debdatta Basu


More information about the Digitalmars-d mailing list