mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
dc90bca33e
Split the OnQuit functionality of Statistics as a separate header and object file. Rework the interface to use lambdas instead of the OnQuitInterface.
30 lines
566 B
C++
30 lines
566 B
C++
#pragma once
|
|
|
|
//
|
|
// This file is distributed under the MIT License. See LICENSE.md for details.
|
|
//
|
|
|
|
#include <cstddef>
|
|
#include <functional>
|
|
#include <vector>
|
|
|
|
#include "llvm/Support/ManagedStatic.h"
|
|
|
|
class OnQuitRegistry {
|
|
private:
|
|
std::vector<std::function<void()>> Registry;
|
|
|
|
public:
|
|
void install();
|
|
|
|
/// Registers an object for having its onQuit method called upon program
|
|
/// termination
|
|
void add(std::function<void()> &&Handler) {
|
|
Registry.push_back(std::move(Handler));
|
|
}
|
|
|
|
void quit();
|
|
};
|
|
|
|
extern llvm::ManagedStatic<OnQuitRegistry> OnQuit;
|