Make file and pipe closing asynchronous.

CloseHandle can block for extended periods of time in certain cases, causing the whole thread to be blocked otherwise.
This commit is contained in:
Sönke Ludwig 2020-05-08 18:31:51 +02:00
parent 86ee5c9477
commit 85dc8d54e6
11 changed files with 165 additions and 94 deletions

View file

@ -36,13 +36,15 @@ void main()
assert(status == IOStatus.ok);
assert(nbytes == data.length - 5);
assert(dst == data);
eventDriver.files.close(f);
() @trusted {
scope (failure) assert(false);
remove("test.txt");
} ();
eventDriver.files.releaseRef(f);
s_done = true;
eventDriver.files.close(f, (f, s) {
assert(s == CloseStatus.ok);
() @trusted {
scope (failure) assert(false);
remove("test.txt");
} ();
eventDriver.files.releaseRef(f);
s_done = true;
});
});
});
});

View file

@ -31,7 +31,7 @@ void main()
void threadFunc(shared(NativeEventDriver) drv)
{
drv.core.runInOwnerThread((id) {
drv.core.runInOwnerThread((int id) {
s_id = id;
}, 42);
}