Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions c++/Source/cthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ MutexStandard Thread::StartGuardLock;
Thread::Thread( const std::string pcName,
uint16_t usStackDepth,
UBaseType_t uxPriority)
: Name(pcName),
StackDepth(usStackDepth),
: handle((TaskHandle_t)-1),
Name(pcName),
StackDepth(usStackDepth),
Priority(uxPriority),
ThreadStarted(false)
{
Expand All @@ -69,10 +70,11 @@ Thread::Thread( const std::string pcName,

Thread::Thread( uint16_t usStackDepth,
UBaseType_t uxPriority)
: Name("Default"),
StackDepth(usStackDepth),
Priority(uxPriority),
ThreadStarted(false)
: handle((TaskHandle_t)-1),
Name("Default"),
StackDepth(usStackDepth),
Priority(uxPriority),
ThreadStarted(false)
{
#if (INCLUDE_vTaskDelayUntil == 1)
delayUntilInitialized = false;
Expand All @@ -89,7 +91,8 @@ Thread::Thread( const char *pcName,
UBaseType_t uxPriority)
: StackDepth(usStackDepth),
Priority(uxPriority),
ThreadStarted(false)
ThreadStarted(false),
handle((TaskHandle_t)-1)
{
for (int i = 0; i < configMAX_TASK_NAME_LEN - 1; i++) {
Name[i] = *pcName;
Expand All @@ -109,7 +112,8 @@ Thread::Thread( uint16_t usStackDepth,
UBaseType_t uxPriority)
: StackDepth(usStackDepth),
Priority(uxPriority),
ThreadStarted(false)
ThreadStarted(false),
handle((TaskHandle_t)-1)
{
memset(Name, 0, sizeof(Name));
#if (INCLUDE_vTaskDelayUntil == 1)
Expand Down
31 changes: 31 additions & 0 deletions c++/Source/include/thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,23 @@ class Thread {
return handle;
}

/**
* Notify a specific thread.
*/
inline void Notify()
{
xTaskNotify( GetHandle(), 0, eNoAction );
}

/**
* Notify a specific thread from ISR context.
*/
inline void NotifyFromISR()
{
BaseType_t higherPriorityTaskWoken = pdFALSE;
xTaskNotifyFromISR( GetHandle(), 0, eNoAction, &higherPriorityTaskWoken );
}

/**
* Yield the scheduler.
*/
Expand Down Expand Up @@ -285,6 +302,20 @@ class Thread {
*/
virtual void Run() = 0;

/**
* Have this thread wait until it gets notification.
*
* @param Timeout Allows you to specify a timeout on the Wait,
* if desired.
*
* @return Notification Value, which can be set/modified when giving
* a notification
*/
inline uint32_t WaitForNotification( TickType_t Timeout = portMAX_DELAY )
{
return ulTaskNotifyTake( pdTRUE, Timeout );
}

#if (INCLUDE_vTaskDelete == 1)
/**
* Called on exit from your Run() routine.
Expand Down