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