// // Created by erki on 24/10/23. // #pragma once #include #include #include #include "cpptick/argstore.hpp" namespace cpptick { struct Scheduler { using StoredCall = std::pair*, ArgStorage>; Utility::Ringbuffer stored_calls; void tick() { if (!stored_calls.empty()) { auto* f = stored_calls.begin()->first; auto& args = stored_calls.begin()->second; (*f)(args); stored_calls.pop_front(); } } ArgStorage& storeCall(Utility::IFunction* call) { // @todo: handle overflow... // still constructs double. stored_calls.emplace_back(call, ArgStorage{}); auto& storage = stored_calls.back().second; storage.reset(); return storage; } }; }