nanosm/doc/hist-design-noodling.txt

42 lines
1.0 KiB
Plaintext
Raw Permalink Normal View History

(this no longer applies and is mostly for historical relevance only)
2024-02-01 04:06:07 -05:00
general
timer:
nanosm::Timer : nanosm::EventLoop::Pollable
bool Set(... duration, ... callback);
// OnReady() will just call the timer callback
proesses:
nanosm::Process : nanosm::EventLoop::Pollable
void Kill();
bool Spawn(... exitCallback);
static std::shared_ptr<Process> SpawnCmdLine();
nanosm::RestartingProcess final : Process
// spawn is shadowed by a version that exits callback to set timerfd-backed timer which on expiry/callback will be cancelled
// then spawn the process again (which will make it have a valid pidfd again etc etc
std::shared_ptr<Timer> timer;
program mainn flow:
main()
parse config (fail if it's bad)
create state (nanosm::NanoSm), from parsed config
create event loop
post callback into event loop to run state
run event loop
nanosm::NanoSm::Run()
spawn wm (if this fails give up and exit early)
for each app (in toml order):
spawn app
return (the event loop wil persist and keep everything alive until it needs to shutdown)