D newbie here. My questions are:
1: How to terminate runTask()? Do I even need to terminate it?
2: Am I destroying the object properly here (from within the class)?
I am running into a situation when I try to free up an object. Consider the following pseudo code:
// app.d
shared static this()
{
listenTCP(25, (conn){
Client client = new Client(conn, db);
});
}
// client.d
class client
{
this(TCPConnection stream)
{
this.conn = stream;
this.task = runTask(
{
while (!this.quit && this.conn.connected())
{
auto ln = cast(string) this.conn.readLine();
this.processLine(ln);
}
});
this.task.join();
}
void close()
{
destroy(this);
}
}
And when a client says "QUIT" I would like to destroy the object using close() but I get an error like so:
object.Error@(0) access violation at line --> while (!this.quit && this.conn.connected())
Thanks for your help