Fix build issue with mutex

This commit is contained in:
David 2024-08-31 19:40:54 +10:00
parent 6c0911038a
commit eb1f80f520
2 changed files with 6 additions and 11 deletions

View File

@ -65,21 +65,18 @@ bool BMP3XXSensor::getMetrics(meshtastic_Telemetry *measurement)
// Get a singleton wrapper for an Adafruit_bmp3xx
BMP3XXSingleton *BMP3XXSingleton::GetInstance()
{
std::lock_guard<std::mutex> lock(mutex_);
if (pinstance_ == nullptr)
if (pinstance == nullptr)
{
pinstance_ = new BMP3XXSingleton();
pinstance = new BMP3XXSingleton();
}
return pinstance_;
return pinstance;
}
BMP3XXSingleton::BMP3XXSingleton(){}
BMP3XXSingleton::~BMP3XXSingleton(){}
BMP3XXSingleton* BMP3XXSingleton::pinstance_{nullptr};
std::mutex BMP3XXSingleton::mutex_;
BMP3XXSingleton* BMP3XXSingleton::pinstance{nullptr};
bool BMP3XXSingleton::performReading()
{

View File

@ -7,7 +7,6 @@
#define SEAL_LEVEL_HPA 1013.2f
#include <mutex>
#include <typeinfo>
#include <Adafruit_BMP3XX.h>
#include "TelemetrySensor.h"
@ -16,15 +15,14 @@
class BMP3XXSingleton : public Adafruit_BMP3XX
{
private:
static BMP3XXSingleton * pinstance_;
static std::mutex mutex_;
static BMP3XXSingleton * pinstance;
protected:
BMP3XXSingleton();
~BMP3XXSingleton();
public:
// Create a singleton instance (with lock for thread safety)
// Create a singleton instance (not thread safe)
static BMP3XXSingleton *GetInstance();
// Singletons should not be cloneable.