On Sun, 12 Nov 2017 20:44:54 +0100, Christian Köstlin wrote:
Hi,
I have an application, that uses vibe as an embedded webserver, but at
the same time does some traditional spawn/spawnLinked work.
I am having problems shutting down the system in a controlled manner.
e.g. vibe catches ctrl-c and shuts down the eventloop, but how can I add
to this hook, to shutdown my own thread?
I found some old newsgroup posts that seemed to use module initializer,
perhaps you could go into more detail?Thanks in advance,
Christian
From my application:
app.d
shared static ~this() // called on exit
{
import core.memory;
if(webInterface !is null)
webInterface.destruct(); // call destruction routine
GC.collect(); // reduce noice in Valgrind report
GC.minimize();// omit if you don't use it
}
In the destruction routine, I send exit message to each background task and wait until they exit, something like this:
myTask.send(ExitMessage());
myTask.join;