Removed correlationId from events - no longer used or needed

This commit is contained in:
Nav
2022-05-01 19:33:22 +01:00
parent 17daa5fbb9
commit 554d4607c5
2 changed files with 4 additions and 15 deletions

View File

@@ -180,8 +180,7 @@ namespace Bloom
*/ */
template<class EventTypeA, class EventTypeB = EventTypeA, class EventTypeC = EventTypeB> template<class EventTypeA, class EventTypeB = EventTypeA, class EventTypeC = EventTypeB>
auto waitForEvent( auto waitForEvent(
std::optional<std::chrono::milliseconds> timeout = std::nullopt, std::optional<std::chrono::milliseconds> timeout = std::nullopt
std::optional<int> correlationId = std::nullopt
) { ) {
// Different return types, depending on how many event type arguments are passed in. // Different return types, depending on how many event type arguments are passed in.
using MonoType = std::optional<Events::SharedEventPointer<EventTypeA>>; using MonoType = std::optional<Events::SharedEventPointer<EventTypeA>>;
@@ -246,25 +245,16 @@ namespace Bloom
} }
Events::SharedGenericEventPointer foundEvent = nullptr; Events::SharedGenericEventPointer foundEvent = nullptr;
auto eventsFound = [&eventTypes, &eventQueueByType, &correlationId, &foundEvent] () -> bool { auto eventsFound = [&eventTypes, &eventQueueByType, &foundEvent] () -> bool {
for (const auto& eventType : eventTypes) { for (const auto& eventType : eventTypes) {
if (eventQueueByType.find(eventType) != eventQueueByType.end() if (eventQueueByType.find(eventType) != eventQueueByType.end()
&& !eventQueueByType.find(eventType)->second.empty() && !eventQueueByType.find(eventType)->second.empty()
) { ) {
auto& queue = eventQueueByType.find(eventType)->second; auto& queue = eventQueueByType.find(eventType)->second;
while (!queue.empty()) { while (!queue.empty()) {
auto event = queue.front(); foundEvent = queue.front();
if (!correlationId.has_value()
|| (event->correlationId.has_value() && event->correlationId == correlationId)
) {
foundEvent = event;
queue.pop();
return true;
}
// Events that match in type but not correlation ID are discarded
queue.pop(); queue.pop();
return true;
} }
} }
} }

View File

@@ -38,7 +38,6 @@ namespace Bloom::Events
public: public:
int id = ++(Event::lastEventId); int id = ++(Event::lastEventId);
QDateTime createdTimestamp = DateTime::currentDateTime(); QDateTime createdTimestamp = DateTime::currentDateTime();
std::optional<int> correlationId;
static constexpr EventType type = EventType::GENERIC; static constexpr EventType type = EventType::GENERIC;
static inline const std::string name = "GenericEvent"; static inline const std::string name = "GenericEvent";