diff --git a/miosix/kernel/queue.h b/miosix/kernel/queue.h index faaa432e0a20cba4e79255e384ce5f2149525443..56e5cd67ecf12722e7ca02ec74093348cc11d8ae 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 cadae7c7b13cac35a911588e9feb9d4b9c637ae3..fd3a49711fc6cf3418603975e28964b9077b3282 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 };