Public Access
Add core runtime: event bus, services, app lifecycle
lib/core is hardware-independent and unit-tested on the host: - EventBus: fixed-size thread-safe queue, delivered on the UI task by dispatch(); drops newest when full and counts drops - Service / ServiceManager: cooperative ticking at per-service intervals, no catch-up bursts, safe across millis() wraparound - App / AppManager: one foreground App, Home always to Launcher, Back offered to the App first, hidden Apps, redraw requests - KeyEvent: logical keys for the upcoming input layer Firmware main loop now ticks services and dispatches events. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "service.h"
|
||||
|
||||
namespace roro {
|
||||
|
||||
class ServiceManager {
|
||||
public:
|
||||
void add(Service& service);
|
||||
|
||||
// Starts services in the order added; each gets its first tick on the next tick() call.
|
||||
void startAll(uint32_t nowMs);
|
||||
// Stops services in reverse order.
|
||||
void stopAll();
|
||||
|
||||
// Ticks every service whose interval has elapsed. Missed intervals are not replayed.
|
||||
void tick(uint32_t nowMs);
|
||||
|
||||
private:
|
||||
struct Entry {
|
||||
Service* service;
|
||||
uint32_t lastTickMs;
|
||||
bool due;
|
||||
};
|
||||
std::vector<Entry> entries_;
|
||||
bool running_ = false;
|
||||
};
|
||||
|
||||
} // namespace roro
|
||||
Reference in New Issue
Block a user