mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-09-01 15:16:22 +00:00
Android: Move host thread lock to a separate file
This commit is contained in:
parent
c8559a7933
commit
5524042922
4 changed files with 55 additions and 39 deletions
24
Source/Android/jni/Host.h
Normal file
24
Source/Android/jni/Host.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2023 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include "Core/Core.h"
|
||||
|
||||
// The Core only supports using a single Host thread.
|
||||
// If multiple threads want to call host functions then they need to queue
|
||||
// sequentially for access.
|
||||
struct HostThreadLock
|
||||
{
|
||||
static std::mutex s_host_identity_mutex;
|
||||
std::unique_lock<std::mutex> m_lock;
|
||||
|
||||
explicit HostThreadLock() : m_lock(s_host_identity_mutex) { Core::DeclareAsHostThread(); }
|
||||
HostThreadLock(const HostThreadLock& other) = delete;
|
||||
HostThreadLock(HostThreadLock&& other) = delete;
|
||||
HostThreadLock& operator=(const HostThreadLock& other) = delete;
|
||||
HostThreadLock& operator=(HostThreadLock&& other) = delete;
|
||||
~HostThreadLock() { Core::UndeclareAsHostThread(); }
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue