shadPS4/src/emulator.h
georgemoralis 15279c42ac
Races and leak fixes part 2 (#4241)
* fixed Unsynchronized free_threads.size()` Read in ThreadState::Free

* fixed data race in posix_pthread_key_create , allocated and seqno are atomic now

* fixed playtime thread

* argv array size fix

* destroy mutex on object deletion with pthread_mutex_destroy

* fixed object_pool
2026-04-09 20:47:47 +03:00

54 lines
1.4 KiB
C++

// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <filesystem>
#include <optional>
#include <thread>
#include "common/singleton.h"
#include "core/linker.h"
#include "input/controller.h"
#include "sdl_window.h"
namespace Core {
using HLEInitDef = void (*)(Core::Loader::SymbolsResolver* sym);
struct SysModules {
std::string_view module_name;
HLEInitDef callback;
};
class Emulator {
public:
Emulator();
~Emulator();
void Run(std::filesystem::path file, std::vector<std::string> args = {},
std::optional<std::filesystem::path> game_folder = {});
void UpdatePlayTime(const std::string& serial);
/**
* This will kill the current process and launch a new process with the same configuration
* (using CLI args) but replacing the eboot image and guest arguments
*/
void Restart(std::filesystem::path eboot_path, const std::vector<std::string>& guest_args = {});
const char* executableName;
bool waitForDebuggerBeforeRun{false};
private:
void LoadSystemModules(const std::string& game_serial);
Core::MemoryManager* memory;
Input::GameControllers* controllers;
Core::Linker* linker;
std::unique_ptr<Frontend::WindowSDL> window;
std::chrono::steady_clock::time_point start_time;
std::jthread play_time_thread;
};
} // namespace Core