Remove MutexLocker

pull/11/head
Geoffrey Merck 4 years ago
parent b32923b11d
commit 414db946ca

@ -945,7 +945,7 @@ bool CDExtraHandler::stateChange()
return stateChange; return stateChange;
} }
void CDExtraHandler::writeStatus(ofstream& file) void CDExtraHandler::writeStatus(std::ofstream& file)
{ {
for (unsigned int i = 0U; i < m_maxReflectors; i++) { for (unsigned int i = 0U; i < m_maxReflectors; i++) {
CDExtraHandler* reflector = m_reflectors[i]; CDExtraHandler* reflector = m_reflectors[i];

@ -909,7 +909,7 @@ bool CDPlusHandler::stateChange()
return stateChange; return stateChange;
} }
void CDPlusHandler::writeStatus(ofstream& file) void CDPlusHandler::writeStatus(std::ofstream& file)
{ {
for (unsigned int i = 0U; i < m_maxReflectors; i++) { for (unsigned int i = 0U; i < m_maxReflectors; i++) {
CDPlusHandler* reflector = m_reflectors[i]; CDPlusHandler* reflector = m_reflectors[i];

@ -1,46 +0,0 @@
/*
* Copyright (C) 2021 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef MUTEXLOCKER_H
#define MUTEXLOCKER_H
#include <mutex>
#include <cassert>
using namespace std;
class CMutexLocker
{
public:
CMutexLocker(recursive_mutex * mutex) :
m_mutex(mutex)
{
assert(mutex != NULL);
m_mutex->lock();
}
~CMutexLocker()
{
m_mutex->unlock();
}
private:
recursive_mutex * m_mutex;
};
#endif

@ -12,7 +12,8 @@
- [4. Contributing](#4-contributing) - [4. Contributing](#4-contributing)
- [4.1. Work Flow](#41-work-flow) - [4.1. Work Flow](#41-work-flow)
- [5. Version History](#5-version-history) - [5. Version History](#5-version-history)
- [5.1. v0.1](#51-v01) - [5.1. v0.x](#51-v0x)
- [5.2. v0.1](#52-v01)
# 1. Introduction # 1. Introduction
This is a port of G4KLX Jonathan Naylor's [ircddbGateway](https://github.com/g4klx/ircDDBGateway). It is wxWidgets free and has minimal dependencies to boost (header libs only), libconfig++ and libcurl This is a port of G4KLX Jonathan Naylor's [ircddbGateway](https://github.com/g4klx/ircDDBGateway). It is wxWidgets free and has minimal dependencies to boost (header libs only), libconfig++ and libcurl
@ -74,5 +75,7 @@ sudo systemctl stop dstargateway.service
I Use [Git flow](https://danielkummer.github.io/git-flow-cheatsheet/) as my workflow. PR are welcome and shall be done against the develop branch and follow the Git Flow branch naming rules. I Use [Git flow](https://danielkummer.github.io/git-flow-cheatsheet/) as my workflow. PR are welcome and shall be done against the develop branch and follow the Git Flow branch naming rules.
# 5. Version History # 5. Version History
## 5.1. v0.1 ## 5.1. v0.x
- Code sanitization
## 5.2. v0.1
First working version First working version

@ -22,8 +22,7 @@
#include <cassert> #include <cassert>
#include <cstring> #include <cstring>
#include <mutex>
#include "MutexLocker.h"
template<class T> class CRingBuffer { template<class T> class CRingBuffer {
public: public:
@ -48,7 +47,7 @@ public:
void addData(const T data) void addData(const T data)
{ {
CMutexLocker locker(&m_mutex); std::lock_guard locker(m_mutex);
m_buffer[m_iPtr++] = data; m_buffer[m_iPtr++] = data;
@ -58,7 +57,7 @@ public:
T getData() T getData()
{ {
CMutexLocker locker(&m_mutex); std::lock_guard locker(m_mutex);
if (m_iPtr == m_oPtr) if (m_iPtr == m_oPtr)
return NULL; return NULL;
@ -73,7 +72,7 @@ public:
void clear() void clear()
{ {
CMutexLocker locker(&m_mutex); std::lock_guard locker(m_mutex);
m_iPtr = 0U; m_iPtr = 0U;
m_oPtr = 0U; m_oPtr = 0U;
@ -83,14 +82,14 @@ public:
bool empty() bool empty()
{ {
CMutexLocker locker(&m_mutex); std::lock_guard locker(m_mutex);
return m_iPtr == m_oPtr; return m_iPtr == m_oPtr;
} }
T peek() T peek()
{ {
CMutexLocker locker(&m_mutex); std::lock_guard locker(m_mutex);
if (m_iPtr == m_oPtr) if (m_iPtr == m_oPtr)
return NULL; return NULL;
@ -103,7 +102,7 @@ private:
T* m_buffer; T* m_buffer;
volatile unsigned int m_iPtr; volatile unsigned int m_iPtr;
volatile unsigned int m_oPtr; volatile unsigned int m_oPtr;
recursive_mutex m_mutex; std::recursive_mutex m_mutex;
}; };
#endif #endif
Loading…
Cancel
Save

Powered by TurnKey Linux.