ftpiiu_plugin/src/BackgroundThread.hpp
2021-10-02 11:22:10 +02:00

50 lines
1.3 KiB
C++

#pragma once
#include "utils/BackgroundThreadWrapper.hpp"
#include <coreinit/cache.h>
#include "utils/logger.h"
#define PORT 21
class BackgroundThread : BackgroundThreadWrapper {
public:
static BackgroundThread *getInstance() {
DCFlushRange(&instance, sizeof(BackgroundThread));
ICInvalidateRange(&instance, sizeof(BackgroundThread));
if (instance == nullptr) {
instance = new BackgroundThread();
DCFlushRange(&instance, sizeof(BackgroundThread));
ICInvalidateRange(&instance, sizeof(BackgroundThread));
}
return instance;
}
static void destroyInstance() {
DCFlushRange(&instance, sizeof(BackgroundThread));
ICInvalidateRange(&instance, sizeof(BackgroundThread));
OSSleepTicks(OSSecondsToTicks(1));
if (instance != nullptr) {
delete instance;
instance = nullptr;
DCFlushRange(&instance, sizeof(BackgroundThread));
ICInvalidateRange(&instance, sizeof(BackgroundThread));
}
}
BackgroundThread();
~BackgroundThread() override;
private:
static int32_t getPriority() {
return 16;
}
BOOL whileLoop() override;
static BackgroundThread *instance;
int serverSocket = -1;
int network_down = 0;
};