From 4e86a76c15896c3f1a6163fa08fcbc677ff6e2f9 Mon Sep 17 00:00:00 2001 From: Terraneo Federico <fede.tft@miosix.org> Date: Sun, 30 Apr 2023 16:26:29 +0200 Subject: [PATCH] Small changes to modernize code style --- miosix/kernel/queue.h | 23 ++++++++++++----------- miosix/kernel/sync.h | 28 ++++++++++++++-------------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/miosix/kernel/queue.h b/miosix/kernel/queue.h index faaa432e..56e5cd67 100644 --- a/miosix/kernel/queue.h +++ b/miosix/kernel/queue.h @@ -163,12 +163,12 @@ public: IRQwakeWaitingThread(); putPos=getPos=numElem=0; } - -private: + //Unwanted methods - Queue(const Queue& s);///< No public copy constructor - Queue& operator = (const Queue& s);///< No publc operator = + Queue(const Queue& s) = delete; + Queue& operator= (const Queue& s) = delete; +private: /** * Wake an eventual waiting thread. * Must be called when interrupts are disabled @@ -359,11 +359,12 @@ public: * Destructor */ ~DynUnsyncQueue() { delete[] data; } - + + //Unwanted methods + DynUnsyncQueue(const DynUnsyncQueue&) = delete; + DynUnsyncQueue& operator=(const DynUnsyncQueue&) = delete; + private: - DynUnsyncQueue(const DynUnsyncQueue&); - DynUnsyncQueue& operator=(const DynUnsyncQueue&); - T *data; unsigned int putPos,getPos; volatile unsigned int queueSize; @@ -510,11 +511,11 @@ public: put=get=cnt=0; } -private: //Unwanted methods - BufferQueue(const BufferQueue&); - BufferQueue& operator=(const BufferQueue&); + BufferQueue(const BufferQueue&) = delete; + BufferQueue& operator=(const BufferQueue&) = delete; +private: T buf[numbuf][size]; // The buffers unsigned int bufSize[numbuf]; //To handle partially empty buffers unsigned char put; //Put pointer diff --git a/miosix/kernel/sync.h b/miosix/kernel/sync.h index cadae7c7..fd3a4971 100644 --- a/miosix/kernel/sync.h +++ b/miosix/kernel/sync.h @@ -115,10 +115,10 @@ public: pthread_mutex_destroy(&impl); } -private: - FastMutex(const FastMutex&); - FastMutex& operator= (const FastMutex&); + FastMutex(const FastMutex&) = delete; + FastMutex& operator= (const FastMutex&) = delete; +private: pthread_mutex_t impl; }; @@ -195,13 +195,12 @@ public: } #endif //SCHED_TYPE_EDF } - -private: + //Unwanted methods - Mutex(const Mutex& s);///< No public copy constructor - Mutex& operator = (const Mutex& s);///< No publc operator = - //Uses default destructor + Mutex(const Mutex& s) = delete; + Mutex& operator= (const Mutex& s) = delete; +private: /** * Lock mutex, can be called only with kernel paused one level deep * (pauseKernel calls can be nested). If another thread holds the mutex, @@ -306,11 +305,11 @@ public: return mutex; } -private: //Unwanted methods - Lock(const Lock& l);///< No public copy constructor - Lock& operator = (const Lock& l);///< No publc operator = + Lock(const Lock& l) = delete; + Lock& operator= (const Lock& l) = delete; +private: T& mutex;///< Reference to locked mutex }; @@ -377,10 +376,11 @@ public: return mutex; } -private: //Unwanted methods - Unlock(const Unlock& l); - Unlock& operator= (const Unlock& l); + Unlock(const Unlock& l) = delete; + Unlock& operator= (const Unlock& l) = delete; + +private: T& mutex;///< Reference to locked mutex }; -- GitLab