Format and .clang-format
This commit is contained in:
1 parent
6aed7b0027
commit
b94b634a87
47 files changed
+42341
-39711
No files matched your search
@@ -1,30 +1,40 @@
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
class SingletonManager {
|
||||
public:
|
||||
// Priority: Higher numbers are destroyed LAST (e.g., Logger = 100)
|
||||
static void registerShutdown(const int priority, const std::function<void()> &shutdownFunc) {
|
||||
m_registry.push_back({priority, shutdownFunc});
|
||||
// Sort so that high priority stays at the end (destroyed last)
|
||||
std::ranges::sort(m_registry, [](const auto& a, const auto& b) {
|
||||
return a.priority < b.priority;
|
||||
});
|
||||
}
|
||||
class SingletonManager
|
||||
{
|
||||
public:
|
||||
|
||||
static void shutdownAll() {
|
||||
// Destroy in reverse priority (highest priority first? No, usually reverse order of arrival)
|
||||
// Here we destroy from lowest priority to highest.
|
||||
for (auto& [priority, func] : m_registry) {
|
||||
std::cerr << priority << ": " << &func << std::endl;
|
||||
func();
|
||||
}
|
||||
m_registry.clear();
|
||||
}
|
||||
// Priority: Higher numbers are destroyed LAST (e.g., Logger = 100)
|
||||
static void registerShutdown(const int priority,
|
||||
const std::function<void()>& shutdownFunc)
|
||||
{
|
||||
m_registry.push_back({priority, shutdownFunc});
|
||||
// Sort so that high priority stays at the end (destroyed last)
|
||||
std::ranges::sort(m_registry, [](const auto& a, const auto& b) {
|
||||
return a.priority < b.priority;
|
||||
});
|
||||
}
|
||||
|
||||
private:
|
||||
struct Entry { int priority; std::function<void()> func; };
|
||||
static inline std::vector<Entry> m_registry;
|
||||
static void shutdownAll()
|
||||
{
|
||||
// Destroy in reverse priority (highest priority first? No, usually
|
||||
// reverse order of arrival) Here we destroy from lowest priority to
|
||||
// highest.
|
||||
for (auto& [priority, func] : m_registry) {
|
||||
std::cerr << priority << ": " << &func << std::endl;
|
||||
func();
|
||||
}
|
||||
m_registry.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
struct Entry {
|
||||
int priority;
|
||||
std::function<void()> func;
|
||||
};
|
||||
static inline std::vector<Entry> m_registry;
|
||||
};
|
||||
Reference in new issue
Block a user