Concurrency.

Debdatta debdatta.basu91 at gmail.com
Mon Nov 28 00:48:20 PST 2011


Jude,

Glad to hear that you found my post informative. Anyway, from what I understand, shared is infectious. However, lets say we have the following:

class A
{
    .......

};
shared class B
{
    constructor()
    {
       myA = new A;
    }
A myA;
}

This will create a problem as the myA is shared, whereas A is not. Hence, we have to tag A to be shared as well. This will lead to most things
marked shared and will cause confusion. Not to mention that default sharing is the convention most programmers have been born with, and thats hard
to change in a person. :D

However, in default shared languages, hiding types is easy. For instance, if I wanted a thread with a completely local context, I would do this:

class myLocalClass : Thread
{
public:
//whatever I want accessible by other classes go here.

void run();

private:

//whatever I want to make specific to my thread will be located here.

}

This seems to be a more elegant solution to the problem. Any thoughts?

-Debdatta




More information about the Digitalmars-d mailing list