CorePartition
Data Structures | Macros | Typedefs | Enumerations | Functions
CorePartition.h File Reference
#include <setjmp.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

Go to the source code of this file.

Data Structures

struct  CpxMsgPayload
 
struct  CpxSmartLock
 
struct  CpxSubscriptions
 
struct  CpxThread
 

Macros

#define Cpx_GetStaticContextSize(nStaticThreadSize)   (nStaticThreadSize >= sizeof (CpxThread) ? (nStaticThreadSize - sizeof (CpxThread)) : 0)
 Return Context size (Stack Memory page) from a Static Memory size. More...
 
#define Cpx_GetStaticThreadSize(nStackMaxSize)   (sizeof (CpxThread) + nStackMaxSize)
 Return the full Static Thread context in bytes. More...
 
#define Cpx_Sleep(nDelayTickTime)
 Will set the thread to a special sleep state. More...
 
#define Cpx_GetStackSize()   Cpx_GetStackSizeByID (Cpx_GetID ())
 Get Current Thread Stack Size. More...
 
#define Cpx_GetMaxStackSize()   Cpx_GetMaxStackSizeByID (Cpx_GetID ())
 Get Current Thread Total Stack context page size. More...
 
#define Cpx_GetContexSize()   (Cpx_GetContextSizeByID (Cpx_GetID ()))
 Return Full context size from current thread. More...
 
#define Cpx_GetStatus()   Cpx_GetStatusByID (Cpx_GetID ())
 Get current Thread Status. More...
 
#define Cpx_GetNice()   Cpx_GetNiceByID (Cpx_GetID ())
 Get Current Thread Nice. More...
 
#define Cpx_GetLastMomentum()   Cpx_GetLastMomentumByID (Cpx_GetID ())
 Get current Thread Last Momentum. More...
 
#define Cpx_GetLastDutyCycle()   Cpx_GetLastDutyCycleByID (Cpx_GetID ())
 Get Current Thread DutyCycle. More...
 
#define Cpx_IsThreadStatic()   Cpx_IsThreadStaticByID (Cpx_GetID ())
 Return if the current thread was statically initiated. More...
 
#define Cpx_IsBrokerStatic()   Cpx_IsThreadStaticByID (Cpx_GetID ())
 Return if the curremt Thread's Broker interface was statically initiated. More...
 
#define Cpx_GetStaticBrokerSize(nMaxTopics)    (sizeof (CpxSubscriptions) + (sizeof (uint32_t) * ((nMaxTopics <= 1) ? sizeof (uint32_t) : nMaxTopics - 1)))
 Return the size of a static Broker Context Size for a Thread. More...
 
#define Cpx_GetStaticBrokerMaxTopics(nStaticSubsSize)    (nStaticSubsSize <= sizeof (CpxSubscriptions) ? 0 : ((nStaticSubsSize - sizeof (CpxSubscriptions)) / sizeof (uint32_t)) + 1)
 
#define Cpx_NotifyVariableLockOne(nLockID, nStatus)   Cpx_NotifyVariableLock (nLockID, nStatus, true)
 Notify one Variable lock waiting for notification. More...
 
#define Cpx_NotifyVariableLockAll(nLockID, nStatus)   Cpx_NotifyVariableLock (nLockID, nStatus, false)
 Notify all Variable lock waiting for notification. More...
 

Typedefs

typedef void(* TopicCallback) (void *pContext, const char *pszTopic, size_t nSize, CpxMsgPayload payLoad)
 
typedef struct CpxSubscriptions CpxSubscriptions
 
typedef uint8_t CpxStaticThread
 
typedef uint8_t CpxStaticBroker
 

Enumerations

enum  __THREADL_TYPES {
  THREADL_NONE = 0 , THREADL_STOPPED , THREADL_LOCK , THREADL_WAITTAG ,
  THREADL_RUNNING = 100 , THREADL_START , THREADL_NOW , THREADL_SLEEP = 200
}
 

Functions

uint32_t Cpx_GetCurrentTick (void)
 
void Cpx_SleepTicks (uint32_t)
 
void Cpx_StackOverflowHandler (void)
 
bool Cpx_Start (size_t nThreadPartitions)
 Start CorePartition thread provisioning. More...
 
bool Cpx_StaticStart (CpxThread **ppStaticThread, size_t nStaticThreadSize)
 Start CorePartition thread provisioning. More...
 
bool Cpx_CreateThread (void(*pFunction)(void *), void *pValue, size_t nStackMaxSize, uint32_t nNice)
 Create a non-Isolated context Thread. More...
 
bool Cpx_CreateStaticThread (void(*pFunction)(void *), void *pValue, CpxStaticThread *pStaticThread, size_t nStaticThreadSize, uint32_t nNice)
 Create a Thread using a static Context + virtual stack page. More...
 
void Cpx_Join (void)
 This will start all the threads. More...
 
uint8_t Cpx_Yield (void)
 Function to be called inside a thread to change context. More...
 
void Cpx_SetSleep (uint32_t nDelayTickTime)
 Will set the thread sleep parameter before Yield. More...
 
size_t Cpx_GetID (void)
 Get Current Thread ID. More...
 
size_t Cpx_GetStackSizeByID (size_t nID)
 Get Current Thread ID. More...
 
size_t Cpx_GetMaxStackSizeByID (size_t nID)
 Get total size of stack context page for a Thread ID. More...
 
size_t Cpx_GetStructContextSize (void)
 Get Thread context size. More...
 
size_t Cpx_GetContextSizeByID (size_t nID)
 Get Full context size (Contex + stack + Broker) More...
 
uint8_t Cpx_GetStatusByID (size_t nID)
 Get a thread status for a thread ID. More...
 
uint32_t Cpx_GetNiceByID (size_t nID)
 Current Thread Nice. More...
 
void Cpx_SetNice (uint32_t nNice)
 Set Current Thread Nice. More...
 
uint32_t Cpx_GetLastMomentumByID (size_t nID)
 Get Current Thread last momentum on switch back. More...
 
uint32_t Cpx_GetLastDutyCycleByID (size_t nID)
 Last Duty Cycle of the current Thread. More...
 
size_t Cpx_GetNumberOfActiveThreads (void)
 Get Number of total active Threads. More...
 
size_t Cpx_GetNumberOfThreads (void)
 Get Number of assigned Threads. More...
 
size_t Cpx_GetMaxNumberOfThreads (void)
 Get Max Number of total active Threads. More...
 
char Cpx_IsSecureByID (size_t nID)
 Return the Secure Status for a thread ID. More...
 
bool Cpx_IsCoreRunning (void)
 Report if there is any running thread. More...
 
bool Cpx_IsThreadStaticByID (size_t nID)
 Return if a Threads was statically initiated. More...
 
bool Cpx_IsBrokerStaticByID (size_t nID)
 Return if a Thread's Broker interface was statically initiated. More...
 
bool Cpx_EnableBroker (void *pUserContext, uint16_t nMaxTopics, TopicCallback callback)
 Enable Broker for the current thread. More...
 
bool Cpx_EnableStaticBroker (void *pUserContext, CpxStaticBroker *pStaticBroker, size_t nStaticBrokerSize, TopicCallback callback)
 Enable Broker for the current thread. More...
 
bool Cpx_SubscribeTopic (const char *pszTopic, size_t length)
 Subscribe for a specific topic. More...
 
bool Cpx_PublishTopic (const char *pszTopic, size_t length, size_t nAttribute, uint64_t nValue)
 Public a tuple Param and Value. More...
 
bool Cpx_IsSubscribed (const char *pszTopic, size_t length)
 Check if the current thread already subscribe to a topic. More...
 
bool Cpx_NotifyOne (const char *pszTag, size_t nTagLength)
 Notify ONE TAG assigned as waiting thread. More...
 
bool Cpx_NotifyMessageOne (const char *pszTag, size_t nTagLength, size_t nAttribute, uint64_t nValue)
 Notify ONE TAGs assigned as waiting thread with a Message payload. More...
 
bool Cpx_NotifyAll (const char *pszTag, size_t nTagLength)
 Notify ALL TAGs assigned as waiting thread. More...
 
bool Cpx_NotifyMessageAll (const char *pszTag, size_t nTagLength, size_t nAttribute, uint64_t nValue)
 Notify ALL TAGs assigned as waiting thread with a Message payload. More...
 
bool Cpx_Wait (const char *pszTag, size_t nTagLength)
 Wait for a specific notification from a given TAG. More...
 
bool Cpx_WaitMessage (const char *pszTag, size_t nTagLength, CpxMsgPayload *payload)
 Wait for a specific notification from a given TAG and payload. More...
 
bool Cpx_LockInit (CpxSmartLock *pLock)
 Init SmartLock variable. More...
 
bool Cpx_Lock (CpxSmartLock *pLock)
 Do a exclusive Lock and set to Simple lock. More...
 
bool Cpx_TryLock (CpxSmartLock *pLock)
 Like Lock() but only locks in case it is unlocked. More...
 
bool Cpx_SharedLock (CpxSmartLock *pLock)
 Can act as multiple locks. More...
 
bool Cpx_Unlock (CpxSmartLock *pLock)
 Unlock exclusive locks. More...
 
bool Cpx_SharedUnlock (CpxSmartLock *pLock)
 Unlock shared locks. More...
 
bool Cpx_WaitVariableLock (void *nLockID, size_t *pnStatus)
 Wait for a Variable Locks notification. More...
 
size_t Cpx_WaitingVariableLock (void *nLockID)
 Return how much threads are locked waiting for a variable notification. More...
 
size_t Cpx_NotifyVariableLock (void *nLockID, size_t nStatus, bool bOneOnly)
 Notify all/one Variable lock waiting for notification. More...
 
void * Cpx_GetLockID (void)
 
void * Cpx_GetLockIDByID (size_t nID)
 

Macro Definition Documentation

◆ Cpx_GetContexSize

#define Cpx_GetContexSize ( )    (Cpx_GetContextSizeByID (Cpx_GetID ()))

Return Full context size from current thread.

◆ Cpx_GetLastDutyCycle

#define Cpx_GetLastDutyCycle ( )    Cpx_GetLastDutyCycleByID (Cpx_GetID ())

Get Current Thread DutyCycle.

◆ Cpx_GetLastMomentum

#define Cpx_GetLastMomentum ( )    Cpx_GetLastMomentumByID (Cpx_GetID ())

Get current Thread Last Momentum.

◆ Cpx_GetMaxStackSize

#define Cpx_GetMaxStackSize ( )    Cpx_GetMaxStackSizeByID (Cpx_GetID ())

Get Current Thread Total Stack context page size.

◆ Cpx_GetNice

#define Cpx_GetNice ( )    Cpx_GetNiceByID (Cpx_GetID ())

Get Current Thread Nice.

◆ Cpx_GetStackSize

#define Cpx_GetStackSize ( )    Cpx_GetStackSizeByID (Cpx_GetID ())

Get Current Thread Stack Size.

◆ Cpx_GetStaticBrokerMaxTopics

#define Cpx_GetStaticBrokerMaxTopics (   nStaticSubsSize)     (nStaticSubsSize <= sizeof (CpxSubscriptions) ? 0 : ((nStaticSubsSize - sizeof (CpxSubscriptions)) / sizeof (uint32_t)) + 1)

◆ Cpx_GetStaticBrokerSize

#define Cpx_GetStaticBrokerSize (   nMaxTopics)     (sizeof (CpxSubscriptions) + (sizeof (uint32_t) * ((nMaxTopics <= 1) ? sizeof (uint32_t) : nMaxTopics - 1)))

Return the size of a static Broker Context Size for a Thread.

Parameters
nMaxTopicsMax number of Topics (minimal 1, smaller will be automatically set to 1)
Returns
The struct + topic list in bytes to be used

◆ Cpx_GetStaticContextSize

#define Cpx_GetStaticContextSize (   nStaticThreadSize)    (nStaticThreadSize >= sizeof (CpxThread) ? (nStaticThreadSize - sizeof (CpxThread)) : 0)

Return Context size (Stack Memory page) from a Static Memory size.

Parameters
nStaticThreadSizeThe size (in bytes) of the stack memory
Returns
the size of the context

◆ Cpx_GetStaticThreadSize

#define Cpx_GetStaticThreadSize (   nStackMaxSize)    (sizeof (CpxThread) + nStackMaxSize)

Return the full Static Thread context in bytes.

Parameters
nStackMaxSizeStack memory page size
Returns
The size of the full Static Thread (context + stak memory page)

◆ Cpx_GetStatus

#define Cpx_GetStatus ( )    Cpx_GetStatusByID (Cpx_GetID ())

Get current Thread Status.

◆ Cpx_IsBrokerStatic

#define Cpx_IsBrokerStatic ( )    Cpx_IsThreadStaticByID (Cpx_GetID ())

Return if the curremt Thread's Broker interface was statically initiated.

Parameters
nIDThread ID
Returns
false if it was not statically initiated

◆ Cpx_IsThreadStatic

#define Cpx_IsThreadStatic ( )    Cpx_IsThreadStaticByID (Cpx_GetID ())

Return if the current thread was statically initiated.

Parameters
nIDThread ID
Returns
false if it was not statically initiated

◆ Cpx_NotifyVariableLockAll

#define Cpx_NotifyVariableLockAll (   nLockID,
  nStatus 
)    Cpx_NotifyVariableLock (nLockID, nStatus, false)

Notify all Variable lock waiting for notification.

Parameters
nLockIDLockID size_t used to notify
nStatusPayload to be sent, a size_t
bOneOnlyIf true only one is notified
Returns
false if LockID is invalid (== 0) or no data

◆ Cpx_NotifyVariableLockOne

#define Cpx_NotifyVariableLockOne (   nLockID,
  nStatus 
)    Cpx_NotifyVariableLock (nLockID, nStatus, true)

Notify one Variable lock waiting for notification.

Parameters
nLockIDLockID size_t used to notify
nStatusPayload to be sent, a size_t
bOneOnlyIf true only one is notified
Returns
false if LockID is invalid (== 0) or no data

◆ Cpx_Sleep

#define Cpx_Sleep (   nDelayTickTime)
Value:
{ \
Cpx_SetSleep (nDelayTickTime); \
Cpx_Yield (); \
}

Will set the thread to a special sleep state.

Parameters
nDelayTickTimeHow much ticks to sleep
Note
if Time has been overridden it tick will correspond to the time frame used by sleep overridden function

Typedef Documentation

◆ CpxStaticBroker

typedef uint8_t CpxStaticBroker

◆ CpxStaticThread

typedef uint8_t CpxStaticThread

◆ CpxSubscriptions

◆ TopicCallback

typedef void(* TopicCallback) (void *pContext, const char *pszTopic, size_t nSize, CpxMsgPayload payLoad)

Enumeration Type Documentation

◆ __THREADL_TYPES

Enumerator
THREADL_NONE 
THREADL_STOPPED 
THREADL_LOCK 
THREADL_WAITTAG 
THREADL_RUNNING 
THREADL_START 
THREADL_NOW 
THREADL_SLEEP 

Function Documentation

◆ Cpx_CreateStaticThread()

bool Cpx_CreateStaticThread ( void(*)(void *)  pFunction,
void *  pValue,
CpxStaticThread pStaticThread,
size_t  nStaticThreadSize,
uint32_t  nNice 
)

Create a Thread using a static Context + virtual stack page.

Parameters
pFunctionFunction (void Function (void* dataPointer)) as thread main
pValuedata that will be injected on Thread creation
pStaticThreadThe Static context + virtual stack pointer
nStaticThreadSizeSize of the Static Thread in bytes
nNiceWhen in time it is good to be used
Note
No memory will be created.
Returns
false In case of parameter error

◆ Cpx_CreateThread()

bool Cpx_CreateThread ( void(*)(void *)  pFunction,
void *  pValue,
size_t  nStackMaxSize,
uint32_t  nNice 
)

Create a non-Isolated context Thread.

Parameters
pFunctionFunction (void Function (void* dataPointer)) as thread main
pValuedata that will be injected on Thread creation
nStackMaxSizeSize of the Stack to be used
nNiceWhen in time it is good to be used
Returns
false fails on more provisioned threads or no more memory to create it
Note
All threads will be create with the size of stack plus context size (~100 bytes)

◆ Cpx_EnableBroker()

bool Cpx_EnableBroker ( void *  pUserContext,
uint16_t  nMaxTopics,
TopicCallback  callback 
)

Enable Broker for the current thread.

Parameters
pUserContextThe default context to be ejected if needed
nMaxTopicsMax topics to be handled by the current thread
callbackCall back to be used to process thread Synchronously
Returns
false failed to create the broker context for the current thread
Note
The default context must not be part of the thread§ stack, or it will be invalid on callback time, please use global variables or from heap (new or malloc memory), AGAIN: NEVER USE A LOCAL FUNCTION VARIABLE AS CONTEXT, USE A GLOBAL VARIABLE OR A ALLOCATED MEMORY.

◆ Cpx_EnableStaticBroker()

bool Cpx_EnableStaticBroker ( void *  pUserContext,
CpxStaticBroker pStaticBroker,
size_t  nStaticBrokerSize,
TopicCallback  callback 
)

Enable Broker for the current thread.

Parameters
pUserContextThe default context to be ejected if needed
pStaticBrokerStatic Broker CpxSubscriptions pointer
nStaticBrokerSizeStatic Broker CpxSubscriptions pointer size in bytes
callbackCall back to be used to process thread Synchronously
Returns
false failed to create the broker context for the current thread
Note
The default context must not be part of the thread stack, or it will be invalid on callback time, please use global variables or from heap (new or malloc memory), AGAIN: NEVER USE A LOCAL FUNCTION VARIABLE AS CONTEXT, USE A GLOBAL VARIABLE OR A ALLOCATED MEMORY.

◆ Cpx_GetContextSizeByID()

size_t Cpx_GetContextSizeByID ( size_t  nID)

Get Full context size (Contex + stack + Broker)

Returns
size_t

◆ Cpx_GetCurrentTick()

uint32_t Cpx_GetCurrentTick ( void  )

◆ Cpx_GetID()

size_t Cpx_GetID ( void  )

Get Current Thread ID.

Returns
size_t Thread ID

◆ Cpx_GetLastDutyCycleByID()

uint32_t Cpx_GetLastDutyCycleByID ( size_t  nID)

Last Duty Cycle of the current Thread.

Parameters
nIDThread ID
Returns
uint32_t time in Tick
Note
Tick will represent the overridden time interface otherwise it will be a single context switch to each.

◆ Cpx_GetLastMomentumByID()

uint32_t Cpx_GetLastMomentumByID ( size_t  nID)

Get Current Thread last momentum on switch back.

Parameters
nIDThread ID
Returns
uint32_t the LastMomentum in Tick
Note
Tick will represent the overridden time interface otherwise it will be a single context switch to each.

◆ Cpx_GetLockID()

void* Cpx_GetLockID ( void  )

◆ Cpx_GetLockIDByID()

void* Cpx_GetLockIDByID ( size_t  nID)

◆ Cpx_GetMaxNumberOfThreads()

size_t Cpx_GetMaxNumberOfThreads ( void  )

Get Max Number of total active Threads.

Returns
size_t number of threads

◆ Cpx_GetMaxStackSizeByID()

size_t Cpx_GetMaxStackSizeByID ( size_t  nID)

Get total size of stack context page for a Thread ID.

Parameters
nIDThread ID
Returns
size_t total size of stack context page

◆ Cpx_GetNiceByID()

uint32_t Cpx_GetNiceByID ( size_t  nID)

Current Thread Nice.

Parameters
nIDThread ID
Returns
uint32_t Nice representing tick
Note
Tick will represent the overridden time interface otherwise it will be a single context switch to each

◆ Cpx_GetNumberOfActiveThreads()

size_t Cpx_GetNumberOfActiveThreads ( void  )

Get Number of total active Threads.

Returns
size_t number of threads

◆ Cpx_GetNumberOfThreads()

size_t Cpx_GetNumberOfThreads ( void  )

Get Number of assigned Threads.

Returns
size_t number of threads

◆ Cpx_GetStackSizeByID()

size_t Cpx_GetStackSizeByID ( size_t  nID)

Get Current Thread ID.

Parameters
nIDA valid ID
Returns
size_t Thread ID
Note
if a non valid ID is provided it will return 0

◆ Cpx_GetStatusByID()

uint8_t Cpx_GetStatusByID ( size_t  nID)

Get a thread status for a thread ID.

Parameters
nIDThread ID
Returns
uint8_t Actual thread context

◆ Cpx_GetStructContextSize()

size_t Cpx_GetStructContextSize ( void  )

Get Thread context size.

Returns
size_t total size of the thread context

◆ Cpx_IsBrokerStaticByID()

bool Cpx_IsBrokerStaticByID ( size_t  nID)

Return if a Thread's Broker interface was statically initiated.

Parameters
nIDThread ID
Returns
false if it was not statically initiated

◆ Cpx_IsCoreRunning()

bool Cpx_IsCoreRunning ( void  )

Report if there is any running thread.

Returns
false in case there is none running

◆ Cpx_IsSecureByID()

char Cpx_IsSecureByID ( size_t  nID)

Return the Secure Status for a thread ID.

Parameters
nIDThread ID
Returns
char return 'S' for secure and 'N' for normal

◆ Cpx_IsSubscribed()

bool Cpx_IsSubscribed ( const char *  pszTopic,
size_t  length 
)

Check if the current thread already subscribe to a topic.

Parameters
pszTopicThe topic for information
lengthThe size of the topic string
Returns
false if it was not subscribed

◆ Cpx_IsThreadStaticByID()

bool Cpx_IsThreadStaticByID ( size_t  nID)

Return if a Threads was statically initiated.

Parameters
nIDThread ID
Returns
false if it was not statically initiated

◆ Cpx_Join()

void Cpx_Join ( void  )

This will start all the threads.

Note
At least ONE thread must be defines before using this function

◆ Cpx_Lock()

bool Cpx_Lock ( CpxSmartLock pLock)

Do a exclusive Lock and set to Simple lock.

Parameters
pLockThe Lock variable
Returns
false the lock is null
Note
Wait till Lock is unlocked (type none) and lock it set to type Simple and lock, SharedLock will wait till it is unlocked.

◆ Cpx_LockInit()

bool Cpx_LockInit ( CpxSmartLock pLock)

Init SmartLock variable.

Parameters
pLockThe Lock variable
Returns
false the lock is null
Note
If you re initialise it will unlock all locks

◆ Cpx_NotifyAll()

bool Cpx_NotifyAll ( const char *  pszTag,
size_t  nTagLength 
)

Notify ALL TAGs assigned as waiting thread.

Parameters
pszTagThe Tag string value
nTagLengthThe length of the tag
Returns
true At least one thread will be notified;
Note
Please note that any notification triggers a context switch yield

◆ Cpx_NotifyMessageAll()

bool Cpx_NotifyMessageAll ( const char *  pszTag,
size_t  nTagLength,
size_t  nAttribute,
uint64_t  nValue 
)

Notify ALL TAGs assigned as waiting thread with a Message payload.

Parameters
pszTagThe TAG string value
nTagLengthThe length of the tag
nAttributeThe Attribute Value to be sent
nValueThe Value of the Attribute to be sent
Returns
true At least one thread will be notified;
Note
Please note that any notification triggers a context switch yield

◆ Cpx_NotifyMessageOne()

bool Cpx_NotifyMessageOne ( const char *  pszTag,
size_t  nTagLength,
size_t  nAttribute,
uint64_t  nValue 
)

Notify ONE TAGs assigned as waiting thread with a Message payload.

Parameters
pszTagThe Tag string value
nTagLengthThe length of the tag
nAttributeThe Attribute Value to be sent
nValueThe Value of the Attribute to be sent
Returns
true At least one thread will be notified;
Note
Please note that any notification triggers a context switch yield

◆ Cpx_NotifyOne()

bool Cpx_NotifyOne ( const char *  pszTag,
size_t  nTagLength 
)

Notify ONE TAG assigned as waiting thread.

Parameters
pszTagThe Tag string value
nTagLengthThe length of the tag
Returns
true At least one thread will be notified;
Note
Please note that any notification triggers a context switch yield

◆ Cpx_NotifyVariableLock()

size_t Cpx_NotifyVariableLock ( void *  nLockID,
size_t  nStatus,
bool  bOneOnly 
)

Notify all/one Variable lock waiting for notification.

Parameters
nLockIDVariable address
nStatusPayload to be sent, a size_t
bOneOnlyIf true only one is notified
Returns
false if LockID is invalid (== 0) or no data

◆ Cpx_PublishTopic()

bool Cpx_PublishTopic ( const char *  pszTopic,
size_t  length,
size_t  nAttribute,
uint64_t  nValue 
)

Public a tuple Param and Value.

Parameters
pszTopicTopic name to publish
lengthThe size of the topic string
nAttributeA attribute to be use to identify the value
nValueA value for the attribute (tuple)
Returns
true If at least one subscriber received the data.

◆ Cpx_SetNice()

void Cpx_SetNice ( uint32_t  nNice)

Set Current Thread Nice.

Parameters
nNiceNice to be used

◆ Cpx_SetSleep()

void Cpx_SetSleep ( uint32_t  nDelayTickTime)

Will set the thread sleep parameter before Yield.

Parameters
nDelayTickTimeHow much ticks to sleep
Note
if Time has been overridden it tick will correspond to the time frame used by sleep overridden function

◆ Cpx_SharedLock()

bool Cpx_SharedLock ( CpxSmartLock pLock)

Can act as multiple locks.

Parameters
pLockThe Lock variable
Returns
false If lock is null
Note
Can acquire multiples locks and lock() will wait till all multiples locks has been unlocked to lock exclusively

◆ Cpx_SharedUnlock()

bool Cpx_SharedUnlock ( CpxSmartLock pLock)

Unlock shared locks.

Parameters
pLockThe Lock variable
Returns
false If lock is null

◆ Cpx_SleepTicks()

void Cpx_SleepTicks ( uint32_t  nSleepTime)

◆ Cpx_StackOverflowHandler()

void Cpx_StackOverflowHandler ( void  )

◆ Cpx_Start()

bool Cpx_Start ( size_t  nThreadPartitions)

Start CorePartition thread provisioning.

Parameters
nThreadPartitionsNumber of threads to be provisioned
Returns
true true if successfully created all provisioned threads

◆ Cpx_StaticStart()

bool Cpx_StaticStart ( CpxThread **  ppStaticThread,
size_t  nStaticThreadSize 
)

Start CorePartition thread provisioning.

Parameters
ppStaticThreadStatic Thread pointer type CpxThread**
nStaticThreadSizeStatic Thread size in bytes
Returns
true true if successfully created all provisioned threads

◆ Cpx_SubscribeTopic()

bool Cpx_SubscribeTopic ( const char *  pszTopic,
size_t  length 
)

Subscribe for a specific topic.

Parameters
pszTopicThe topic to listen for information
lengthThe size of the topic string
Returns
false if there is no more room for a new subscription

◆ Cpx_TryLock()

bool Cpx_TryLock ( CpxSmartLock pLock)

Like Lock() but only locks in case it is unlocked.

Parameters
pLockThe Lock variable
Returns
false If lock is null or lock is locked
Note
Wait till exclusive Lock is unlocked (type none) and lock it set to type Simple and lock, SharedLock will wait till it is unlocked.

◆ Cpx_Unlock()

bool Cpx_Unlock ( CpxSmartLock pLock)

Unlock exclusive locks.

Parameters
pLockThe Lock variable
Returns
false If lock is null

◆ Cpx_Wait()

bool Cpx_Wait ( const char *  pszTag,
size_t  nTagLength 
)

Wait for a specific notification from a given TAG.

Parameters
pszTagThe Tag string value
nTagLengthThe length of the tag
Returns
true For success on receiving notification

◆ Cpx_WaitingVariableLock()

size_t Cpx_WaitingVariableLock ( void *  nLockID)

Return how much threads are locked waiting for a variable notification.

Parameters
nLockIDVariable address
Returns
size_t How much active waiting for a variable

◆ Cpx_WaitMessage()

bool Cpx_WaitMessage ( const char *  pszTag,
size_t  nTagLength,
CpxMsgPayload payload 
)

Wait for a specific notification from a given TAG and payload.

Parameters
pszTagThe Tag string value
nTagLengthThe length of the tag
payloadThe payload with the information sent by other thread
Returns
false if an error occurred
Note
if a Tag was notified using NotifyOne or NotifyAll the thread will receive 0 otherwise will receive the same value sent.

◆ Cpx_WaitVariableLock()

bool Cpx_WaitVariableLock ( void *  nLockID,
size_t *  pnStatus 
)

Wait for a Variable Locks notification.

Parameters
nLockIDVariable address
pnStatusPayload to be sent, a size_t
Returns
false if LockID is invalid (== 0) or no data

◆ Cpx_Yield()

uint8_t Cpx_Yield ( void  )

Function to be called inside a thread to change context.

Returns
true always return true while the thread is valid
Note
Cooperative state yield, should not be used with preemption for speed reasons, that will not complay with LockKernel, for this use PreemptionYield.