mn::queue::basic_work_queue Class Referenceabstract

#include <mn_workqueue.hpp>

+ Inheritance diagram for mn::queue::basic_work_queue:
+ Collaboration diagram for mn::queue::basic_work_queue:

Public Member Functions

 basic_work_queue (basic_task::priority uiPriority, uint16_t usStackDepth, uint8_t uiMaxWorkItems)
 
virtual ~basic_work_queue ()
 
virtual int create (int iCore=MN_THREAD_CONFIG_DEFAULT_WORKQUEUE_CORE)
 
virtual void destroy ()
 
virtual int queue (work_queue_item_t *work, unsigned int timeout=MN_THREAD_CONFIG_TIMEOUT_QUEUE_DEFAULT)
 
volatile bool & running ()
 
uint8_t get_num_items_worked ()
 
uint8_t get_num_items_error ()
 
bool is_ready ()
 

Protected Member Functions

virtual work_queue_itemget_next_item (unsigned int timeout)
 
virtual int create_engine (int iCore)=0
 
virtual void destroy_engine ()=0
 

Protected Attributes

queue_tm_pWorkItemQueue
 
mutex_t m_ThreadStatus
 
mutex_t m_ThreadJob
 
basic_task::priority m_uiPriority
 
uint16_t m_usStackDepth
 
uint8_t m_uiMaxWorkItems
 
volatile uint8_t m_uiNumWorks
 
volatile uint8_t m_uiErrorsNumWorks
 
volatile bool m_bRunning
 

Friends

class work_queue_task
 

Detailed Description

This abstract class is the base "engine" class for all work_queues. basic_work_queue pull work_queue_item off of a FIFO queue and run them sequentially.

This is an abstract base class. To use this, you need to subclass it. All of your basic_work_queue should be derived from the basic_work_queue class. Then implement the virtual create_engine and destroy_engine functions.

Constructor & Destructor Documentation

◆ basic_work_queue()

mn::queue::basic_work_queue::basic_work_queue ( basic_task::priority  uiPriority,
uint16_t  usStackDepth,
uint8_t  uiMaxWorkItems 
)

Our constructor.

Parameters
NameName of the task internal to the WorkQueue.
uiPriorityFreeRTOS priority of this WorkQueue task.
usStackDepthNumber of "words" allocated for the WorkQueue task stack.

◆ ~basic_work_queue()

mn::queue::basic_work_queue::~basic_work_queue ( )
virtual

Our destructor.

Member Function Documentation

◆ create()

int mn::queue::basic_work_queue::create ( int  iCore = MN_THREAD_CONFIG_DEFAULT_WORKQUEUE_CORE)
virtual

Create and start the work queue engine

Returns
'ERR_WORKQUEUE_OK' The workqueue are created, 'ERR_WORKQUEUE_ALREADYINIT' the workqueue was allready created, 'ERR_WORKQUEUE_CANTCREATE' error to create the workqueue and 'ERR_WORKQUEUE_WARNING' not all threads are created in the multi engine workqueue
Note
call internal on_create, for your real engine creating

◆ create_engine()

virtual int mn::queue::basic_work_queue::create_engine ( int  iCore)
protectedpure virtual

Implementation of your actual create code. You must override this function.

Parameters
iCoreuiCore on which core run this thread (i. e. task ), -1 for current core
Note
Don't forget to set the running flag to true

Implemented in mn::queue::basic_work_queue_single, and mn::queue::basic_work_queue_multi.

◆ destroy()

void mn::queue::basic_work_queue::destroy ( )
virtual

Destroy and set the running flag to false

Note
call internal on_destroy, for your real engine creating

◆ destroy_engine()

virtual void mn::queue::basic_work_queue::destroy_engine ( )
protectedpure virtual

Implementation of your actual destroy code. You must override this function.

Implemented in mn::queue::basic_work_queue_single, and mn::queue::basic_work_queue_multi.

◆ get_next_item()

work_queue_item * mn::queue::basic_work_queue::get_next_item ( unsigned int  timeout)
protectedvirtual

Get the next item / job from queue

Parameters
timeoutHow long to wait to get an item / job from the queue.
Returns
The next item / job from list and NULL when list empty or timeout

◆ get_num_items_error()

uint8_t mn::queue::basic_work_queue::get_num_items_error ( )

How many items/jobs are not sucessfull worked

◆ get_num_items_worked()

uint8_t mn::queue::basic_work_queue::get_num_items_worked ( )

How many items / jobs are sucessfull worked

◆ is_ready()

bool mn::queue::basic_work_queue::is_ready ( )

Is the workqueue ready, all jobs/items are worked?

Returns
true If workqueue is ready, false If not

◆ queue()

int mn::queue::basic_work_queue::queue ( work_queue_item_t work,
unsigned int  timeout = MN_THREAD_CONFIG_TIMEOUT_QUEUE_DEFAULT 
)
virtual

Send a work_queue_item_t off to be executed.

Parameters
workPointer to a work_queue_item_t.
Note
This function may block if the basic_work_queue is presently full.
Returns
  • ERR_WORKQUEUE_OK The work_queue_item_t are added
  • ERR_WORKQUEUE_ADD If The work_queue_item_t are not added

◆ running()

volatile bool& mn::queue::basic_work_queue::running ( )
inline

Is the workqueue running?

Returns
true If the workqueue running, false If not

Friends And Related Function Documentation

◆ work_queue_task

friend class work_queue_task
friend

Member Data Documentation

◆ m_bRunning

volatile bool mn::queue::basic_work_queue::m_bRunning
protected

Flag whether or not the workqueue was started.

◆ m_pWorkItemQueue

queue_t* mn::queue::basic_work_queue::m_pWorkItemQueue
protected

The job queue for all workqueues

◆ m_ThreadJob

mutex_t mn::queue::basic_work_queue::m_ThreadJob
protected

Lock Objekt for thread safty Mutex lock for the job queue

◆ m_ThreadStatus

mutex_t mn::queue::basic_work_queue::m_ThreadStatus
protected

Lock Objekt for thread safty Mutex lock for status and flags changes

◆ m_uiErrorsNumWorks

volatile uint8_t mn::queue::basic_work_queue::m_uiErrorsNumWorks
protected

Holder of num works are not successfull run

◆ m_uiMaxWorkItems

uint8_t mn::queue::basic_work_queue::m_uiMaxWorkItems
protected

◆ m_uiNumWorks

volatile uint8_t mn::queue::basic_work_queue::m_uiNumWorks
protected

Holder of num works are successfull run

◆ m_uiPriority

basic_task::priority mn::queue::basic_work_queue::m_uiPriority
protected

◆ m_usStackDepth

uint16_t mn::queue::basic_work_queue::m_usStackDepth
protected

The documentation for this class was generated from the following files: