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

Add Deferred(DispatchQueue*) #817

Merged
merged 4 commits into from
Nov 3, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions autowiring/Deferred.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#pragma once

class CoreThread;
class DispatchQueue;

/// <summary>
/// Marker return type for deferred calls
Expand All @@ -13,4 +14,5 @@ class CoreThread;
class Deferred {
public:
Deferred(CoreThread* pThread) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this ctor completely.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Deferred(DispatchQueue* pQueue) {}
};
33 changes: 33 additions & 0 deletions src/autowiring/test/AutoFilterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,39 @@ TEST_F(AutoFilterTest, DeferredDecorateOnly) {
ASSERT_EQ(105, dec->i) << "Deferred decorate-only AutoFilter did not properly attach before context termination";
}

class DQueueSharedPointer:
public DispatchQueue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tab this one out

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

{
public:
DQueueSharedPointer(void)
{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this ctor, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


size_t callCount = 0;

Deferred AutoFilter(std::shared_ptr<const int>) {
callCount++;
return Deferred(this);
}
};

TEST_F(AutoFilterTest, DQueueAutoFilterTest) {
AutoRequired<AutoPacketFactory> factory;
auto ptr = std::make_shared<int>(1012);

auto dQueueSharedPtr = AutoRequired<DQueueSharedPointer>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not AutoRequired<DQueueSharedPointer> dQueueSharedPtr;?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


// Generate a bunch of packets, all with the same shared pointer decoration:
for(size_t i = 0; i < 100; i++) {
// Decorate the packet, forget about it:
auto packet = factory->NewPacket();
packet->Decorate(ptr);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably want to add ASSERT_EQ(0UL, dQueueSharedPtr->callCount) at this point, so we can be assured that the filter is not called prematurely.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the last thing, then I'll merge.

dQueueSharedPtr->DispatchAllEvents();

// Ensure nothing got cached unexpectedly, and that the call count is precisely what we want
ASSERT_EQ(100UL, dQueueSharedPtr->callCount) << "The expected number of calls to AutoFilter were not made";
}

class MyInheritingAutoFilter:
public FilterGen<std::vector<int>>
{};
Expand Down