slige/runtime/vm_provider.hpp

36 lines
719 B
C++
Raw Normal View History

#pragma once
#include "vm.hpp"
2024-12-15 02:07:33 +00:00
#include <cstdint>
2024-12-15 00:32:21 +00:00
#include <mutex>
#include <thread>
2024-12-15 02:07:33 +00:00
#include <vector>
namespace sliger::rpc {
class VmProvider {
public:
VmProvider() { }
2024-12-15 02:07:33 +00:00
VmProvider(const VmProvider&) = delete;
VmProvider operator=(const VmProvider&) = delete;
VmProvider(VmProvider&&) = delete;
VmProvider operator=(VmProvider&&) = delete;
auto load_and_start(std::vector<uint32_t> instructions) -> void;
auto flame_graph_json() -> std::optional<std::string>;
auto code_coverage_json() -> std::optional<std::string>;
2024-12-15 00:32:21 +00:00
auto done() -> bool;
private:
2024-12-15 00:32:21 +00:00
void run_timeslot();
std::mutex mutex;
std::optional<VM> vm;
2024-12-15 00:32:21 +00:00
std::optional<std::thread> running_thread;
};
}