From dbee140d0ab18f0912fb0cc11281d07f40e88e94 Mon Sep 17 00:00:00 2001
From: Daniele Cattaneo <daniele3.cattaneo@mail.polimi.it>
Date: Tue, 11 Apr 2023 22:20:16 +0200
Subject: [PATCH] Rename CondData to WaitToken as it is not used just by
 condition variables anymore.

Signed-off-by: Terraneo Federico <fede.tft@miosix.org>
---
 miosix/kernel/sync.cpp | 14 +++++++-------
 miosix/kernel/sync.h   | 11 ++++++-----
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/miosix/kernel/sync.cpp b/miosix/kernel/sync.cpp
index 90f58212..e7d4541e 100644
--- a/miosix/kernel/sync.cpp
+++ b/miosix/kernel/sync.cpp
@@ -372,7 +372,7 @@ void ConditionVariable::wait(Mutex& m)
 {
     PauseKernelLock dLock;
     Thread *t=Thread::getCurrentThread();
-    CondData listItem(t);
+    WaitToken listItem(t);
     condList.push_back(&listItem); //Add entry to tail of list
 
     //Unlock mutex and wait
@@ -393,7 +393,7 @@ void ConditionVariable::wait(pthread_mutex_t *m)
 {
     FastInterruptDisableLock dLock;
     Thread *t=Thread::IRQgetCurrentThread();
-    CondData listItem(t);
+    WaitToken listItem(t);
     condList.push_back(&listItem); //Putting this thread last on the list (lifo policy)
     t->flags.IRQsetCondWait(true);
 
@@ -415,7 +415,7 @@ TimedWaitResult ConditionVariable::timedWait(Mutex& m, long long absTime)
 
     PauseKernelLock dLock;
     Thread *t=Thread::getCurrentThread();
-    CondData listItem(t);
+    WaitToken listItem(t);
     condList.push_back(&listItem); //Add entry to tail of list
     SleepData sleepData(t,absTime);
     {
@@ -455,7 +455,7 @@ TimedWaitResult ConditionVariable::timedWait(pthread_mutex_t *m, long long absTi
     absTime=std::max(absTime,100000LL);
     FastInterruptDisableLock dLock;
     Thread *t=Thread::IRQgetCurrentThread();
-    CondData listItem(t);
+    WaitToken listItem(t);
     condList.push_back(&listItem); //Putting this thread last on the list (lifo policy)
     SleepData sleepData(t,absTime);
     IRQaddToSleepingList(&sleepData); //Putting this thread on the sleeping list too
@@ -538,7 +538,7 @@ Thread *Semaphore::IRQsignalNoPreempt()
         count++;
         return nullptr;
     }
-    CondData *cd=fifo.front();
+    WaitToken *cd=fifo.front();
     Thread *t=cd->thread;
     fifo.pop_front();
     t->flags.IRQsetCondWait(false);
@@ -586,7 +586,7 @@ void Semaphore::wait()
     }
     //Otherwise put ourselves in queue and wait
     Thread *t=Thread::getCurrentThread();
-    CondData listItem(t);
+    WaitToken listItem(t);
     fifo.push_back(&listItem); //Add entry to tail of list
     t->flags.IRQsetCondWait(true);
     {
@@ -614,7 +614,7 @@ TimedWaitResult Semaphore::timedWait(long long absTime)
     }
     //Otherwise put ourselves in queue...
     Thread *t=Thread::getCurrentThread();
-    CondData listItem(t);
+    WaitToken listItem(t);
     fifo.push_back(&listItem);
     //...and simultaneously to sleep
     SleepData sleepData(t,absTime);
diff --git a/miosix/kernel/sync.h b/miosix/kernel/sync.h
index 972d0af7..4ba75725 100644
--- a/miosix/kernel/sync.h
+++ b/miosix/kernel/sync.h
@@ -388,12 +388,13 @@ private:
 /**
  * \internal
  * This class is used to make a list of threads that are waiting on a condition
- * variable. It is used by the kernel, and should not be used by end users.
+ * variable or on a semaphore. It is used by the kernel, and should not be used
+ * by end users.
  */
-class CondData : public IntrusiveListItem
+class WaitToken : public IntrusiveListItem
 {
 public:
-    CondData(Thread *thread) : thread(thread) {}
+    WaitToken(Thread *thread) : thread(thread) {}
     Thread *thread; ///<\internal Thread that is waiting
 };
 
@@ -530,7 +531,7 @@ private:
     friend int ::pthread_cond_destroy(pthread_cond_t *cond);
 
     //Memory layout must be kept in sync with pthread_cond, see pthread.cpp
-    IntrusiveList<CondData> condList;
+    IntrusiveList<WaitToken> condList;
 };
 
 /**
@@ -634,7 +635,7 @@ private:
     inline Thread *IRQsignalNoPreempt();
 
     volatile unsigned int count; ///< Counter of the semaphore
-    IntrusiveList<CondData> fifo; ///< List of waiting threads
+    IntrusiveList<WaitToken> fifo; ///< List of waiting threads
 };
 
 /**
-- 
GitLab