ftpiiu_plugin/src/BackgroundThread.hpp

43 lines
828 B
C++
Raw Normal View History

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 "utils/logger.h"
2022-02-04 14:33:59 +01:00
#include <coreinit/cache.h>
2019-11-24 14:20:08 +01:00
2022-02-04 14:33:59 +01:00
#define PORT 21
2019-11-24 14:20:08 +01:00
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
if (instance == nullptr) {
2019-11-24 14:20:08 +01:00
instance = new BackgroundThread();
2022-10-06 23:16:31 +02:00
OSMemoryBarrier();
2019-11-24 14:20:08 +01:00
}
return instance;
}
static void destroyInstance() {
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;
2022-10-06 23:16:31 +02:00
OSMemoryBarrier();
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() {
2022-10-07 14:17:53 +02:00
return 16;
2019-11-24 14:20:08 +01:00
}
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;
};