|
Open Model Railroad Network (OpenMRN)
|
Implementation the ExecutorBase with a specific number of priority bands. More...
#include <Executor.hxx>
Public Member Functions | |
| Executor (const char *name, int priority, size_t stack_size) | |
| Constructor. | |
| Executor (const NO_THREAD &unused) | |
| Constructor that does not create a thread for running the executor. | |
| void | start_thread (const char *name, int priority, size_t stack_size) |
| Creates a new thread for running this executor. | |
| ~Executor () | |
| Destructor. | |
| void | add (Executable *msg, unsigned priority=UINT_MAX) OVERRIDE |
| Send a message to this Executor's queue. | |
| void | thread_body () |
| If the executor was created with NO_THREAD, then this function needs to be called to run the executor loop. | |
| bool | empty () OVERRIDE |
| uint32_t | sequence () OVERRIDE |
Public Member Functions inherited from ExecutorBase | |
| ExecutorBase () | |
| Constructor. | |
| ~ExecutorBase () | |
| Destructor. | |
| void | sync_run (std::function< void()> fn) |
| Synchronously runs a closure on this executor. | |
| void | select (Selectable *job) |
| Adds a file descriptor to be watched to the select loop. | |
| bool | is_selected (Selectable *job) |
| void | unselect (Selectable *job) |
| Removes a job from the select loop. | |
| bool | loop_once () |
| Performs one loop of the execution on the calling thread. | |
| long long | loop_some () ICACHE_FLASH_ATTR |
| Performs a few loops of the executor on the calling thread. | |
| ActiveTimers * | active_timers () |
| void | shutdown () |
| Terminates the executor thread. | |
| os_thread_t | thread_handle () |
| OSThread & | thread () |
| void | assert_current () |
| Die if we are not on the current executor. | |
| Executable * | current () |
| Helper function for debugging and tracing. | |
Public Member Functions inherited from LinkedObject< ExecutorBase > | |
| ExecutorBase * | link_next () |
Private Member Functions | |
| Executable * | next (unsigned *priority) OVERRIDE |
| Retrieve an item from the front of the queue. | |
| Executor () | |
| Default Constructor. | |
| DISALLOW_COPY_AND_ASSIGN (Executor) | |
Private Attributes | |
| QListProtected< NUM_PRIO > | queue_ |
| Internal queue of executables waiting to be scheduled. | |
Additional Inherited Members | |
Static Public Member Functions inherited from ExecutorBase | |
| static ExecutorBase * | by_name (const char *name, bool wait) |
| Lookup an executor by its name. | |
Static Public Member Functions inherited from LinkedObject< ExecutorBase > | |
| static ExecutorBase * | link_head () |
| static Atomic * | head_mu () |
| Locks the list for modification (at any entry!). | |
Protected Member Functions inherited from ExecutorBase | |
| void * | entry () override |
| Thread entry point. | |
| void | run () override |
| Entry point. | |
| DISALLOW_COPY_AND_ASSIGN (ExecutorBase) | |
| OSThread (const char *name, int priority, size_t stack_size, void *(*start_routine)(void *), void *arg) | |
| Create a thread. | |
| OSThread () | |
| Creates a thread via inheritance. | |
| void | start (const char *name, int priority, size_t stack_size) |
| Starts the thread. | |
| virtual | ~OSThread () |
| Default destructor. | |
| bool | is_created () |
| void | inherit () |
| Inherits the current thread. | |
| os_thread_t | get_handle () |
| void | lock_to_thread () |
| Sets the thread handle to the current calling thread's. | |
| void | unlock_from_thread () |
| Resets the thread handle to none. | |
Protected Member Functions inherited from Executable | |
| void | test_deletion () |
| void | notify () override |
| Crashes the program – everyone who is expecting notify calls must override this function. | |
| virtual void | alloc_result (QMember *item) |
| Return the result of an alloc_async() from a memory Pool. | |
Protected Member Functions inherited from QMember | |
| QMember () | |
| Constructor. | |
| ~QMember () | |
| Destructor. | |
| void | init () |
| Initiailize a QMember, in place of a public placement construction. | |
Protected Member Functions inherited from LinkedObject< ExecutorBase > | |
| ExecutorBase * | link_this () |
| LinkedObject () | |
| Constructor. Puts *this on the linked list. | |
| ~LinkedObject () | |
| Constructor. Removes *this from the linked list. | |
| ExecutorBase * | link_next () |
Static Protected Member Functions inherited from OSThread | |
| static int | getpriority (OSThread *thread) |
| Return the current thread priority. | |
| static int | get_priority (OSThread *thread) |
| Return the current thread priority. | |
| static int | get_priority_min () |
| Get the minimum thread priority. | |
| static int | get_priority_max () |
| Get the maximum thread priority. | |
Static Protected Member Functions inherited from LinkedObject< ExecutorBase > | |
| static ExecutorBase * | link_head () |
| static Atomic * | head_mu () |
| Locks the list for modification (at any entry!). | |
Protected Attributes inherited from ExecutorBase | |
| OSSelectWakeup | selectHelper_ |
| Helper object for interruptible select calls. | |
| volatile unsigned | sequence_: 25 |
| Sequence number. | |
Protected Attributes inherited from QMember | |
| QMember * | next |
| pointer to the next member in the queue | |
Protected Attributes inherited from LinkedObject< ExecutorBase > | |
| ExecutorBase * | link_ |
| Linked list pointer. | |
Static Protected Attributes inherited from LinkedObject< ExecutorBase > | |
| static ExecutorBase * | head_ |
| Beginning of the list. | |
Implementation the ExecutorBase with a specific number of priority bands.
The memory usage and scheduling cost is proportional to the number of priority bands, so it should be kept pretty low.
Definition at line 265 of file Executor.hxx.
|
inline |
Constructor.
| name | name of executor |
| priority | thread priority |
| stack_size | thread stack size |
Definition at line 274 of file Executor.hxx.
|
inlineexplicit |
Constructor that does not create a thread for running the executor.
The owner should later create a thread to this executor by calling the start_thread() function or donate a thread by calling thread_body() function.
| unused | unused – just here for polymorphic disalbiguation. |
Definition at line 284 of file Executor.hxx.
Destructor.
Destructs the executor.
Waits for the executor to run out of work first.
Definition at line 411 of file Executor.hxx.
|
inlinevirtual |
Send a message to this Executor's queue.
| msg | Executable instance to insert into the input queue |
| priority | priority of message |
Implements ExecutorBase.
Definition at line 306 of file Executor.hxx.
Implements ExecutorBase.
Definition at line 350 of file Executor.hxx.
|
inlineprivatevirtual |
Retrieve an item from the front of the queue.
| priority | pass back the priority of the queue pulled from |
Implements ExecutorBase.
Definition at line 362 of file Executor.hxx.
|
inlinevirtual |
Implements ExecutorBase.
Definition at line 355 of file Executor.hxx.
|
inline |
Creates a new thread for running this executor.
| name | thread name (passed to OS) |
| priority | thread priority (0 == default prio) |
| stack_size | number of bytes to allocate for the thread stack; used only for FreeRTOS and ignored on linux etc. |
Definition at line 293 of file Executor.hxx.
|
inline |
If the executor was created with NO_THREAD, then this function needs to be called to run the executor loop.
It will exit when the execut gets shut down. Useful for having an executor loop run in the main thread.
Definition at line 344 of file Executor.hxx.
|
private |
Internal queue of executables waiting to be scheduled.
Definition at line 376 of file Executor.hxx.