[darwin] use CFRunLoopSourceInvalidate() to also cancel any pending AsyncTask invocations

This commit is contained in:
Konstantin Käfer
2016-04-12 12:00:11 -07:00
parent 23a0e2a84e
commit 618b9f1dbf
2 changed files with 28 additions and 1 deletions

View File

@@ -64,6 +64,33 @@ TEST(AsyncTask, DestroyShouldNotRunQueue) {
EXPECT_EQ(count, 0);
}
TEST(AsyncTask, DestroyAfterSignaling) {
RunLoop loop;
// We're creating two tasks and signal both of them; the one that gets fired first destroys
// the other one. Make sure that the second one we destroyed doesn't fire.
std::unique_ptr<AsyncTask> task1, task2;
task1 = std::make_unique<AsyncTask>([&] {
task2.reset();
if (!task1) {
FAIL() << "Task was destroyed but invoked anyway";
}
});
task2 = std::make_unique<AsyncTask>([&] {
task1.reset();
if (!task2) {
FAIL() << "Task was destroyed but invoked anyway";
}
});
task1->send();
task2->send();
loop.runOnce();
}
TEST(AsyncTask, RequestCoalescingMultithreaded) {
RunLoop loop;