mirror of
https://github.com/zeldaret/botw
synced 2026-05-28 00:15:56 -04:00
ksys: Start adding MessageDispatcher
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#include "KingSystem/Utils/Thread/MessageProcessor.h"
|
||||
#include <tuple>
|
||||
#include "KingSystem/Utils/Thread/Message.h"
|
||||
#include "KingSystem/Utils/Thread/MessageAck.h"
|
||||
#include "KingSystem/Utils/Thread/MessageReceiver.h"
|
||||
@@ -10,18 +9,6 @@ MessageProcessor::MessageProcessor(Logger* logger) : mLogger(logger) {}
|
||||
|
||||
MessageProcessor::~MessageProcessor() = default;
|
||||
|
||||
static bool checkTransceiver(const MesTransceiverId& id) {
|
||||
if (!id.next)
|
||||
return false;
|
||||
|
||||
MesTransceiverId* next = *id.next;
|
||||
if (!next)
|
||||
return false;
|
||||
|
||||
const auto& fields = [](const MesTransceiverId& i) { return std::tie(i.queue_id, i.id); };
|
||||
return fields(id) == fields(*next);
|
||||
}
|
||||
|
||||
bool MessageProcessor::process(Message* message) {
|
||||
message->decrementDelay();
|
||||
|
||||
@@ -32,17 +19,17 @@ bool MessageProcessor::process(Message* message) {
|
||||
bool dest_valid = false;
|
||||
|
||||
const auto& dest = message->getDestination();
|
||||
if (checkTransceiver(dest)) {
|
||||
if (Message::checkTransceiver(dest)) {
|
||||
success = dest.receiver->receive(*message) & 1;
|
||||
mLogger->log(*message, success);
|
||||
dest_valid = true;
|
||||
}
|
||||
|
||||
const auto& src = message->getSource();
|
||||
if (!message->hasDelayer() || checkTransceiver(src)) {
|
||||
if (!message->hasDelayer() || Message::checkTransceiver(src)) {
|
||||
if (message->shouldAck()) {
|
||||
const auto& source = message->getSource();
|
||||
if (checkTransceiver(source)) {
|
||||
if (Message::checkTransceiver(source)) {
|
||||
auto* receiver = source.receiver;
|
||||
const MessageAck ack{dest_valid, success, message->getDestination(),
|
||||
message->getType(), message->getUserData()};
|
||||
|
||||
Reference in New Issue
Block a user