Explicitly dispose the event driver on thread shutdown.

Handle multiple calls to dispose() gracefully, because external code may already make an explicit call to dispose().
This commit is contained in:
Sönke Ludwig 2017-11-23 17:18:33 +01:00
parent 1cadc3077b
commit aa9a08f571
3 changed files with 9 additions and 0 deletions

View file

@ -30,6 +30,11 @@ static if (!is(NativeEventDriver == EventDriver)) {
if (!s_driver) s_driver = new NativeEventDriver;
}
static ~this()
{
s_driver.dispose();
}
shared static this()
{
s_driver = new NativeEventDriver;

View file

@ -89,9 +89,11 @@ final class PosixEventDriver(Loop : PosixEventLoop) : EventDriver {
final override void dispose()
{
if (!m_loop) return;
m_files.dispose();
m_dns.dispose();
m_loop.dispose();
m_loop = null;
}
}

View file

@ -72,7 +72,9 @@ final class WinAPIEventDriver : EventDriver {
override void dispose()
{
if (!m_events) return;
m_events.dispose();
m_events = null;
assert(threadInstance !is null);
threadInstance = null;
}