import core.thread;
class A
{
Thread mThread;
bool mStopped;
this()
{
mThread = new Thread(&run);
mThread.start();
}
void run()
{
while (!mStopped)
{
//do stuff
}
}
~this()
{
mStopped = true;
mThread.join();
}
}
void main()
{
auto a = new A;
delete a; //need this or the program hangs
}
In both gdc and dmd I need to use manually delete this object or
the program is blocked after main. Is by design ?
It seems undesirable, as the thread can be many layers of
encapsulation down, and they all need manual deletes.