mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-30 11:24:16 +01:00
Merge pull request #9224 from liamwhite/services-arent-processes
service_thread: remove explicit KProcess
This commit is contained in:
commit
b51c1544b9
@ -20,8 +20,12 @@ void KEvent::Initialize(KProcess* owner) {
|
|||||||
m_readable_event.Initialize(this);
|
m_readable_event.Initialize(this);
|
||||||
|
|
||||||
// Set our owner process.
|
// Set our owner process.
|
||||||
m_owner = owner;
|
// HACK: this should never be nullptr, but service threads don't have a
|
||||||
m_owner->Open();
|
// proper parent process yet.
|
||||||
|
if (owner != nullptr) {
|
||||||
|
m_owner = owner;
|
||||||
|
m_owner->Open();
|
||||||
|
}
|
||||||
|
|
||||||
// Mark initialized.
|
// Mark initialized.
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
@ -50,8 +54,11 @@ Result KEvent::Clear() {
|
|||||||
void KEvent::PostDestroy(uintptr_t arg) {
|
void KEvent::PostDestroy(uintptr_t arg) {
|
||||||
// Release the event count resource the owner process holds.
|
// Release the event count resource the owner process holds.
|
||||||
KProcess* owner = reinterpret_cast<KProcess*>(arg);
|
KProcess* owner = reinterpret_cast<KProcess*>(arg);
|
||||||
owner->GetResourceLimit()->Release(LimitableResource::EventCountMax, 1);
|
|
||||||
owner->Close();
|
if (owner != nullptr) {
|
||||||
|
owner->GetResourceLimit()->Release(LimitableResource::EventCountMax, 1);
|
||||||
|
owner->Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Kernel
|
} // namespace Kernel
|
||||||
|
@ -40,7 +40,6 @@ private:
|
|||||||
std::mutex m_session_mutex;
|
std::mutex m_session_mutex;
|
||||||
std::map<KServerSession*, std::shared_ptr<SessionRequestManager>> m_sessions;
|
std::map<KServerSession*, std::shared_ptr<SessionRequestManager>> m_sessions;
|
||||||
KEvent* m_wakeup_event;
|
KEvent* m_wakeup_event;
|
||||||
KProcess* m_process;
|
|
||||||
KThread* m_thread;
|
KThread* m_thread;
|
||||||
std::atomic<bool> m_shutdown_requested;
|
std::atomic<bool> m_shutdown_requested;
|
||||||
const std::string m_service_name;
|
const std::string m_service_name;
|
||||||
@ -180,39 +179,17 @@ ServiceThread::Impl::~Impl() {
|
|||||||
|
|
||||||
// Close thread.
|
// Close thread.
|
||||||
m_thread->Close();
|
m_thread->Close();
|
||||||
|
|
||||||
// Close process.
|
|
||||||
m_process->Close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceThread::Impl::Impl(KernelCore& kernel_, const std::string& service_name)
|
ServiceThread::Impl::Impl(KernelCore& kernel_, const std::string& service_name)
|
||||||
: kernel{kernel_}, m_service_name{service_name} {
|
: kernel{kernel_}, m_service_name{service_name} {
|
||||||
// Initialize process.
|
|
||||||
m_process = KProcess::Create(kernel);
|
|
||||||
KProcess::Initialize(m_process, kernel.System(), service_name,
|
|
||||||
KProcess::ProcessType::KernelInternal, kernel.GetSystemResourceLimit());
|
|
||||||
|
|
||||||
// Reserve a new event from the process resource limit
|
|
||||||
KScopedResourceReservation event_reservation(m_process, LimitableResource::EventCountMax);
|
|
||||||
ASSERT(event_reservation.Succeeded());
|
|
||||||
|
|
||||||
// Initialize event.
|
// Initialize event.
|
||||||
m_wakeup_event = KEvent::Create(kernel);
|
m_wakeup_event = KEvent::Create(kernel);
|
||||||
m_wakeup_event->Initialize(m_process);
|
m_wakeup_event->Initialize(nullptr);
|
||||||
|
|
||||||
// Commit the event reservation.
|
|
||||||
event_reservation.Commit();
|
|
||||||
|
|
||||||
// Reserve a new thread from the process resource limit
|
|
||||||
KScopedResourceReservation thread_reservation(m_process, LimitableResource::ThreadCountMax);
|
|
||||||
ASSERT(thread_reservation.Succeeded());
|
|
||||||
|
|
||||||
// Initialize thread.
|
// Initialize thread.
|
||||||
m_thread = KThread::Create(kernel);
|
m_thread = KThread::Create(kernel);
|
||||||
ASSERT(KThread::InitializeDummyThread(m_thread, m_process).IsSuccess());
|
ASSERT(KThread::InitializeDummyThread(m_thread, nullptr).IsSuccess());
|
||||||
|
|
||||||
// Commit the thread reservation.
|
|
||||||
thread_reservation.Commit();
|
|
||||||
|
|
||||||
// Start thread.
|
// Start thread.
|
||||||
m_host_thread = std::jthread([this] { LoopProcess(); });
|
m_host_thread = std::jthread([this] { LoopProcess(); });
|
||||||
|
Loading…
Reference in New Issue
Block a user