ccpr: Use SkMessageBus for thread-safe eviction of cache entries
Bug: skia:
Change-Id: I87725b95761deb689333315ce681a4968d98190a
Reviewed-on: https://skia-review.googlesource.com/c/163511
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/tests/MessageBusTest.cpp b/tests/MessageBusTest.cpp
index 145176b..d184149 100644
--- a/tests/MessageBusTest.cpp
+++ b/tests/MessageBusTest.cpp
@@ -9,13 +9,18 @@
#include "Test.h"
namespace {
+
struct TestMessage {
- bool shouldSend(uint32_t inboxID) const { return true; }
TestMessage(int i, float f) : x(i), y(f) {}
int x;
float y;
};
+
+static inline bool SkShouldPostMessageToBus(const TestMessage&, uint32_t) {
+ return true;
+}
+
}
DECLARE_SKMESSAGEBUS_MESSAGE(TestMessage)
@@ -56,21 +61,24 @@
}
namespace {
+
struct AddressedMessage {
uint32_t fInboxID;
-
- bool shouldSend(uint32_t inboxID) const {
- SkASSERT(inboxID);
- if (!fInboxID) {
- return true;
- }
- return inboxID == fInboxID;
- }
};
+
+static inline bool SkShouldPostMessageToBus(const AddressedMessage& msg, uint32_t msgBusUniqueID) {
+ SkASSERT(msgBusUniqueID);
+ if (!msg.fInboxID) {
+ return true;
+ }
+ return msgBusUniqueID == msg.fInboxID;
}
+
+}
+
DECLARE_SKMESSAGEBUS_MESSAGE(AddressedMessage)
-DEF_TEST(MessageBus_shouldSend, r) {
+DEF_TEST(MessageBus_SkShouldPostMessageToBus, r) {
SkMessageBus<AddressedMessage>::Inbox inbox1(1), inbox2(2);
SkMessageBus<AddressedMessage>::Post({0}); // Should go to both