deleted copyctor and copy assignment

This commit is contained in:
Robin Müller 2020-05-20 12:50:56 +02:00
parent 338651af2f
commit f6b17d6e2e
2 changed files with 4 additions and 25 deletions

View File

@ -15,27 +15,6 @@ BinarySemaphore::~BinarySemaphore() {
vSemaphoreDelete(handle);
}
// This copy ctor is important as it prevents the assignment to a ressource
// (other.handle) variable which is later deleted!
BinarySemaphore::BinarySemaphore(const BinarySemaphore& other) {
handle = xSemaphoreCreateBinary();
if(handle == nullptr) {
sif::error << "Binary semaphore creation failure" << std::endl;
}
xSemaphoreGive(handle);
}
BinarySemaphore& BinarySemaphore::operator =(const BinarySemaphore& s) {
if(this != &s) {
handle = xSemaphoreCreateBinary();
if(handle == nullptr) {
sif::error << "Binary semaphore creation failure" << std::endl;
}
xSemaphoreGive(handle);
}
return *this;
}
BinarySemaphore::BinarySemaphore(BinarySemaphore&& s) {
handle = xSemaphoreCreateBinary();
if(handle == nullptr) {

View File

@ -39,10 +39,10 @@ public:
//! @brief Default ctor
BinarySemaphore();
//! @brief Copy ctor
BinarySemaphore(const BinarySemaphore&);
//! @brief Copy assignment
BinarySemaphore& operator=(const BinarySemaphore&);
//! @brief Copy ctor, deleted explicitely.
BinarySemaphore(const BinarySemaphore&) = delete;
//! @brief Copy assignment, deleted explicitely.
BinarySemaphore& operator=(const BinarySemaphore&) = delete;
//! @brief Move ctor
BinarySemaphore (BinarySemaphore &&);
//! @brief Move assignment