30 static std::mutex g_vcpu_manager_mutex;
46 auto ___ = gsl::on_failure([&]
48 std::lock_guard<std::mutex> guard(g_vcpu_manager_mutex);
49 m_vcpus.erase(vcpuid);
52 if (
auto &&
vcpu = add_vcpu(vcpuid, data))
59 auto ___ = gsl::finally([&]
61 std::lock_guard<std::mutex> guard(g_vcpu_manager_mutex);
62 m_vcpus.erase(vcpuid);
65 if (
auto &&
vcpu = get_vcpu(vcpuid))
72 if (
auto &&
vcpu = get_vcpu(vcpuid))
79 if (
auto &&
vcpu = get_vcpu(vcpuid))
90 vcpu_manager::vcpu_manager()
noexcept :
94 std::unique_ptr<vcpu> &
98 throw std::runtime_error(
"invalid vcpu factory");
100 if (
auto &&
vcpu = get_vcpu(vcpuid))
103 if (
auto &&
vcpu = m_vcpu_factory->make_vcpu(vcpuid, data))
105 std::lock_guard<std::mutex> guard(g_vcpu_manager_mutex);
106 return m_vcpus[vcpuid] = std::move(
vcpu);
109 throw std::runtime_error(
"make_vcpu returned a nullptr vcpu");
112 std::unique_ptr<vcpu> &
115 std::lock_guard<std::mutex> guard(g_vcpu_manager_mutex);
116 return m_vcpus[vcpuid];
virtual void run_vcpu(vcpuid::type vcpuid, user_data *data=nullptr)
int64_t unsigned long void * data
virtual void run(user_data *data=nullptr)
virtual void create_vcpu(vcpuid::type vcpuid, user_data *data=nullptr)
void uint64_t uint64_t uint64_t *rdx noexcept
virtual void init(user_data *data=nullptr)
constexpr const auto string
virtual void write(vcpuid::type vcpuid, const std::string &str) noexcept
virtual void hlt_vcpu(vcpuid::type vcpuid, user_data *data=nullptr)
virtual void hlt(user_data *data=nullptr)
virtual void delete_vcpu(vcpuid::type vcpuid, user_data *data=nullptr)
virtual void write(const std::string &str) noexcept
virtual void fini(user_data *data=nullptr)
static vcpu_manager * instance() noexcept