ME507 Utility Library  0.2.1
Mechatronics Course Support Software for ARM/Arduino/FreeRTOS
taskshare.h File Reference

Data which can be shared between tasks in a thread-safe manner. More...

#include "baseshare.h"
#include "FreeRTOS.h"
Include dependency graph for taskshare.h:

Go to the source code of this file.

Classes

class  Share< DataType >
 Class for data to be shared in a thread-safe manner between tasks. More...
 

Detailed Description

Data which can be shared between tasks in a thread-safe manner.

This file contains a template class for data which is to be shared between tasks. The data must be protected against damage due to context switches, so it is protected by a mutex or by causing transfers to take place inside critical sections of code which are not interrupted. This version is known to work on STM32's and ESP32's only because the insertion and extraction operators << and >> need specific functions to determine if they're running in ISR's or not.

Date
2012-Oct-29 JRR Original file
2014-Aug-26 JRR Changed file names, class name to TaskShare, removed unused version that uses semaphores, renamed put() and get()
2014-Oct-18 JRR Added linked list of all shares for tracking and debugging
2020-Oct-10 JRR Made compatible with Arduino, class name to Share
2020-Nov-14 JRR Added new-ESP32 compatible SHARE_..._CRITICAL(x); added << and >> operators
2020-Nov-18 JRR Critical sections not reliable; changed to a queue
2021-Sep-17 JRR Changed some put params from references to copies
2021-Sep-19 JRR Added overloads for get() which return values