Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DispatchQueue length on Cancel #1023

Merged
merged 2 commits into from
Aug 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/autowiring/DispatchQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ bool DispatchQueue::Cancel(void) {
// Found a ready thunk, run from here:
thunk.reset(m_pHead);
m_pHead = thunk->m_pFlink;
m_count--;
}
else if (!m_delayedQueue.empty()) {
auto& f = m_delayedQueue.top();
Expand Down
2 changes: 2 additions & 0 deletions src/autowiring/test/DispatchQueueTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@ TEST_F(DispatchQueueTest, SimpleCancel) {
DispatchQueue dq;
auto called = std::make_shared<bool>(false);
dq += [called] { *called = true; };
ASSERT_EQ(1U, dq.GetDispatchQueueLength());
ASSERT_TRUE(dq.Cancel()) << "Dispatch queue failed to cancel a lambda as expected";
ASSERT_EQ(0U, dq.GetDispatchQueueLength());
ASSERT_FALSE(dq.DispatchEvent()) << "Succeeded in dispatching an event that should not have been dispatched";
ASSERT_FALSE(*called) << "Dispatch queue executed a lambda that should have been destroyed";
ASSERT_TRUE(called.unique()) << "Dispatch queue leaked a lambda function";
Expand Down