Added module base for task routing

This commit is contained in:
2026-03-24 00:01:36 +01:00
parent 5b774f485a
commit 25ad777247
6 changed files with 99 additions and 0 deletions

24
src/base/router.h Normal file
View File

@@ -0,0 +1,24 @@
#pragma once
#include "base/task.h"
#include "base/module_base.h"
#include "base/modules.h"
namespace router {
int send(const Task& task) {
if (task.target >= MOD_COUNT) {
return 1;
}
module_base* mod = modules[task.target];
if (mod == nullptr) {
return 1;
}
return mod->push(task);
}
int send(module_id target, task_type type, uint32_t data=0) {
Task t{target, type, data};
return send(t);
}
}