Defer driver dispose in main thread to shared static ~this.
Allows dependent code to still access the driver from within their shared static ~this. vibe-core notably falls into this category.
This commit is contained in:
parent
2d4ccf454d
commit
29aee9ee52
|
@ -32,12 +32,19 @@ static if (!is(NativeEventDriver == EventDriver)) {
|
|||
|
||||
static ~this()
|
||||
{
|
||||
s_driver.dispose();
|
||||
if (!s_isMainThread)
|
||||
s_driver.dispose();
|
||||
}
|
||||
|
||||
shared static this()
|
||||
{
|
||||
s_driver = new NativeEventDriver;
|
||||
s_isMainThread = true;
|
||||
}
|
||||
|
||||
shared static ~this()
|
||||
{
|
||||
s_driver.dispose();
|
||||
}
|
||||
} else {
|
||||
void setupEventDriver(EventDriver driver)
|
||||
|
@ -48,4 +55,7 @@ static if (!is(NativeEventDriver == EventDriver)) {
|
|||
}
|
||||
}
|
||||
|
||||
private NativeEventDriver s_driver;
|
||||
private {
|
||||
NativeEventDriver s_driver;
|
||||
bool s_isMainThread;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue