Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Namespaces | Functions | Variables
user_command_queue.h File Reference

Run the user commands and user callbacks of other threads on the main loop. More...

Go to the source code of this file.

Namespaces

namespace  lampda
 Program scope.
 
namespace  lampda::logic
 Handle the main high level logics.
 
namespace  lampda::logic::user_command_queue
 Defer the user commands to the main loop.
 

Functions

bool lampda::logic::user_command_queue::post (const common::UserCommand &command)
 Post a user command, run by the main loop on its next tick. Thread safe.
 
void lampda::logic::user_command_queue::request_brightness_user_callback ()
 Request a call to the user brightness callback (see brightness::force_brightness_user_callback()), run by the main loop on its next tick, after the posted commands. Thread safe. Several requests before the next tick result in a single call.
 
size_t lampda::logic::user_command_queue::get_pending_count ()
 Return the number of commands waiting for the main loop. Thread safe.
 
void lampda::logic::user_command_queue::loop ()
 Main loop only: run the posted commands, in order, then the requested brightness callback.
 

Variables

static constexpr size_t lampda::logic::user_command_queue::maxStoredCommands = 16
 Maximum number of commands waiting for the main loop.
 

Detailed Description

Run the user commands and user callbacks of other threads on the main loop.

The user code (modes, lamp object, strip buffers, brightness callbacks) is not thread safe and must only run on the main loop. Threads other than the main loop (sun timer task, bluetooth callback task, ...) must not call user::handle_user_command() or user::brightness_update() directly: they post a request here, and the main loop runs it on its next tick.