This commit is contained in:
altalk23 2024-02-25 10:04:29 +03:00
parent 3ede15b6e2
commit 9a47d611cc
2 changed files with 11 additions and 16 deletions

View file

@ -33,11 +33,21 @@ namespace geode {
protected:
std::string m_id;
static auto& pools() {
static std::unordered_map<std::string, EventListenerPool*> s_pools;
return s_pools;
}
public:
using Ev = DispatchEvent<Args...>;
using Callback = ListenerResult(Args...);
EventListenerPool* getPool() const override;
EventListenerPool* getPool() const override {
if (pools().count(m_id) == 0) {
pools()[m_id] = new DefaultEventListenerPool();
}
return pools()[m_id];
}
ListenerResult handle(utils::MiniFunction<Callback> fn, Ev* event) {
if (event->getID() == m_id) {

View file

@ -1,15 +0,0 @@
#include <Geode/loader/Dispatch.hpp>
#include <Geode/utils/ranges.hpp>
#include <mutex>
#include <unordered_map>
using namespace geode::prelude;
static std::unordered_map<std::string, EventListenerPool*> s_pools;
EventListenerPool* DispatchFilter::getPool() const {
if (s_pools.count(m_id) == 0) {
s_pools[m_id] = new DefaultEventListenerPool();
}
return s_pools[m_id];
}