Elma
An event loop manager for embedded systems
|
The Process Manager class. More...
#include <manager.h>
Public Member Functions | |
Manager () | |
Default constructor. | |
Manager & | schedule (Process &process, high_resolution_clock::duration period) |
Manager & | remove (Process &process) |
Manager & | all (std::function< void(Process &)> f) |
Manager & | set_priority (Process &process, int priority) |
Manager & | sort_processes () |
Manager & | init () |
Manager & | start () |
Manager & | update () |
Manager & | stop () |
Manager & | use_simulated_time () |
Manager & | use_real_time () |
Manager & | run (high_resolution_clock::duration runtime) |
Manager & | run () |
Manager & | run (std::function< bool()> condition) |
high_resolution_clock::time_point | start_time () |
high_resolution_clock::duration | elapsed () |
std::mutex & | get_update_mutex () |
Manager & | set_niceness (high_resolution_clock::duration n) |
Manager & | add_channel (Channel &) |
Channel & | channel (string) |
Manager & | watch (string event_name, std::function< void(Event &)> handler) |
Manager & | emit (const Event &event) |
Client & | client () |
Example usage:
Add a channel to the manager
The | channel to be added |
Definition at line 43 of file manager.cc.
Apply a function to all processes.
f | The function to apply. It should take a reference to a process and return void. |
Definition at line 100 of file manager.cc.
Channel & elma::Manager::channel | ( | string | name | ) |
Retrieve a reference to an existing channel. Throws an error if no such channel exists.
Definition at line 50 of file manager.cc.
|
inline |
Emit an event associated with a name. Typically, a process would emit events in its update() method using something like the following code"
where value is any jsonable value. For example, you can write
event | The Event to be emitted |
Definition at line 85 of file manager.cc.
|
inline |
Manager & elma::Manager::init | ( | ) |
Initialize all processes. Usually called before run()
Definition at line 109 of file manager.cc.
Remove a Process from the manager so it will no longer be updated. Calls its stop() method.
process | The process to be removed. |
Definition at line 31 of file manager.cc.
Manager & elma::Manager::run | ( | high_resolution_clock::duration | runtime | ) |
Run the manager for the specified amount of time.
The | desired amount of time to run |
Definition at line 190 of file manager.cc.
Manager & elma::Manager::run | ( | ) |
Run the manager indefinitely or until a process calls halt().
Definition at line 198 of file manager.cc.
Manager & elma::Manager::run | ( | std::function< bool()> | condition | ) |
Run the manager until the provided contion is true or until a process calls halt().
The | condition, a function returning a boolean and taking no arguments. |
Definition at line 207 of file manager.cc.
Add a Process to the manager, to be run at a certain frequency.
process | The process to be scheduled, usually derived from the Process abstract base class |
period | The desired duration of time between updates |
Definition at line 13 of file manager.cc.
|
inline |
Set Process Priority and sort _Processes to ensure higher priority are updated first. Priority may be set -5 (low priority) to 15 (high priority) This should allow priority adjustment while running.
process | The process you want to adjust priority level. |
priority,a | integer between -5 and 15 |
Definition at line 176 of file manager.cc.
Manager & elma::Manager::sort_processes | ( | ) |
sort _Processes based on _priority to ensure higher priority process are updated first.
Definition at line 144 of file manager.cc.
Manager & elma::Manager::start | ( | ) |
Start all processes. Usually not called directly.
Definition at line 116 of file manager.cc.
|
inline |
Manager & elma::Manager::stop | ( | ) |
Stop all processes. Usually not called directly.
Definition at line 123 of file manager.cc.
Manager & elma::Manager::update | ( | ) |
Update all processes if enough time has passed. Usually not called directly.
Definition at line 130 of file manager.cc.
Manager & elma::Manager::use_real_time | ( | ) |
Sets if the manager will run in real time. In real time, the manager will continually advance time until the next process needs to update.
If | the manager runs in simulated time. |
Definition at line 165 of file manager.cc.
Manager & elma::Manager::use_simulated_time | ( | ) |
Sets if the manager will run in simulated time. In simulated time, the next schefuled process will immediately run at the completion of the last.
Definition at line 156 of file manager.cc.
Watch for an event associated with the given name. For watching events, you would typically register event handlers in your process' init() method. For example,
event_name | The name of the event A function or lambda that takes an event and returns nothing. |
Definition at line 68 of file manager.cc.