slige/runtime/vm_provider.hpp
2024-12-15 03:07:33 +01:00

36 lines
719 B
C++

#pragma once
#include "vm.hpp"
#include <cstdint>
#include <mutex>
#include <thread>
#include <vector>
namespace sliger::rpc {
class VmProvider {
public:
VmProvider() { }
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>;
auto done() -> bool;
private:
void run_timeslot();
std::mutex mutex;
std::optional<VM> vm;
std::optional<std::thread> running_thread;
};
}