mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Use magic statics instead of ATOMIC_STATIC. (#109)
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "Handle.h"
|
||||
|
||||
using namespace cs;
|
||||
|
||||
ATOMIC_STATIC_INIT(Sources)
|
||||
ATOMIC_STATIC_INIT(Sinks)
|
||||
@@ -79,7 +79,7 @@ class Sources
|
||||
: public UnlimitedHandleResource<Handle, SourceData, Handle::kSource> {
|
||||
public:
|
||||
static Sources& GetInstance() {
|
||||
ATOMIC_STATIC(Sources, instance);
|
||||
static Sources instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
@@ -91,8 +91,6 @@ class Sources
|
||||
|
||||
private:
|
||||
Sources() = default;
|
||||
|
||||
ATOMIC_STATIC_DECL(Sources)
|
||||
};
|
||||
|
||||
struct SinkData {
|
||||
@@ -108,7 +106,7 @@ struct SinkData {
|
||||
class Sinks : public UnlimitedHandleResource<Handle, SinkData, Handle::kSink> {
|
||||
public:
|
||||
static Sinks& GetInstance() {
|
||||
ATOMIC_STATIC(Sinks, instance);
|
||||
static Sinks instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
@@ -119,8 +117,6 @@ class Sinks : public UnlimitedHandleResource<Handle, SinkData, Handle::kSink> {
|
||||
|
||||
private:
|
||||
Sinks() = default;
|
||||
|
||||
ATOMIC_STATIC_DECL(Sinks)
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
|
||||
using namespace cs;
|
||||
|
||||
ATOMIC_STATIC_INIT(Logger)
|
||||
|
||||
static void def_log_func(unsigned int level, const char* file,
|
||||
unsigned int line, const char* msg) {
|
||||
llvm::SmallString<128> buf;
|
||||
|
||||
@@ -9,14 +9,13 @@
|
||||
#define CSCORE_LOG_H_
|
||||
|
||||
#include <support/Logger.h>
|
||||
#include <support/atomic_static.h>
|
||||
|
||||
namespace cs {
|
||||
|
||||
class Logger : public wpi::Logger {
|
||||
public:
|
||||
static Logger& GetInstance() {
|
||||
ATOMIC_STATIC(Logger, instance);
|
||||
static Logger instance;
|
||||
return instance;
|
||||
}
|
||||
~Logger();
|
||||
@@ -25,8 +24,6 @@ class Logger : public wpi::Logger {
|
||||
|
||||
private:
|
||||
Logger();
|
||||
|
||||
ATOMIC_STATIC_DECL(Logger)
|
||||
};
|
||||
|
||||
#define LOG(level, x) WPI_LOG(cs::Logger::GetInstance(), level, x)
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
|
||||
using namespace cs;
|
||||
|
||||
ATOMIC_STATIC_INIT(NetworkListener)
|
||||
|
||||
class NetworkListener::Thread : public wpi::SafeThread {
|
||||
public:
|
||||
void Main();
|
||||
|
||||
@@ -9,14 +9,13 @@
|
||||
#define CSCORE_NETWORKLISTENER_H_
|
||||
|
||||
#include <support/SafeThread.h>
|
||||
#include <support/atomic_static.h>
|
||||
|
||||
namespace cs {
|
||||
|
||||
class NetworkListener {
|
||||
public:
|
||||
static NetworkListener& GetInstance() {
|
||||
ATOMIC_STATIC(NetworkListener, instance);
|
||||
static NetworkListener instance;
|
||||
return instance;
|
||||
}
|
||||
~NetworkListener();
|
||||
@@ -29,8 +28,6 @@ class NetworkListener {
|
||||
|
||||
class Thread;
|
||||
wpi::SafeThreadOwner<Thread> m_owner;
|
||||
|
||||
ATOMIC_STATIC_DECL(NetworkListener)
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
using namespace cs;
|
||||
|
||||
ATOMIC_STATIC_INIT(Notifier)
|
||||
bool Notifier::s_destroyed = false;
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <functional>
|
||||
|
||||
#include <support/SafeThread.h>
|
||||
#include <support/atomic_static.h>
|
||||
|
||||
#include "cscore_cpp.h"
|
||||
|
||||
@@ -25,7 +24,7 @@ class Notifier {
|
||||
|
||||
public:
|
||||
static Notifier& GetInstance() {
|
||||
ATOMIC_STATIC(Notifier, instance);
|
||||
static Notifier instance;
|
||||
return instance;
|
||||
}
|
||||
~Notifier();
|
||||
@@ -64,8 +63,6 @@ class Notifier {
|
||||
|
||||
std::function<void()> m_on_start;
|
||||
std::function<void()> m_on_exit;
|
||||
|
||||
ATOMIC_STATIC_DECL(Notifier)
|
||||
static bool s_destroyed;
|
||||
};
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include <llvm/ArrayRef.h>
|
||||
#include <llvm/SmallVector.h>
|
||||
#include <support/atomic_static.h>
|
||||
#include <support/mutex.h>
|
||||
|
||||
namespace cs {
|
||||
@@ -169,14 +168,12 @@ class StaticUnlimitedHandleResource
|
||||
: public UnlimitedHandleResource<THandle, TStruct, typeValue, TMutex> {
|
||||
public:
|
||||
static StaticUnlimitedHandleResource& GetInstance() {
|
||||
ATOMIC_STATIC(StaticUnlimitedHandleResource, instance);
|
||||
static StaticUnlimitedHandleResource instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
private:
|
||||
StaticUnlimitedHandleResource() = default;
|
||||
|
||||
ATOMIC_STATIC_DECL(StaticUnlimitedHandleResource)
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
|
||||
@@ -1482,8 +1482,6 @@ typedef JSingletonCallbackManager<LogMessage> LoggerJNI;
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
ATOMIC_STATIC_INIT(LoggerJNI)
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user