summaryrefslogtreecommitdiff
path: root/Source/Android
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2025-11-16 18:35:17 +0100
committerGitHub <noreply@github.com>2025-11-16 18:35:17 +0100
commitb6e062f2e3838b9b80cc7694fa9dc0eaca80aff4 (patch)
tree77a14a64a8d462c14d73a9b5c8e95fbc7b1b8286 /Source/Android
parent3ff4985120fd6be0a2f38cd489ec9349b8865c1c (diff)
parent068947e2b613d15f724c87c501949c9105cc7f7f (diff)
Merge pull request #13689 from JosJuice/lock-core-any-thread
Core: Let any thread call previously host-thread-only functions
Diffstat (limited to 'Source/Android')
-rw-r--r--Source/Android/jni/Host.h25
1 files changed, 6 insertions, 19 deletions
diff --git a/Source/Android/jni/Host.h b/Source/Android/jni/Host.h
index 3a7a304825..0183038d9a 100644
--- a/Source/Android/jni/Host.h
+++ b/Source/Android/jni/Host.h
@@ -5,37 +5,24 @@
#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.
+// TODO: The above isn't true anymore, so we should get rid of this class.
struct HostThreadLock
{
- explicit HostThreadLock() : m_lock(s_host_identity_mutex) { Core::DeclareAsHostThread(); }
+ explicit HostThreadLock() : m_lock(s_host_identity_mutex) {}
- ~HostThreadLock()
- {
- if (m_lock.owns_lock())
- Core::UndeclareAsHostThread();
- }
+ ~HostThreadLock() = default;
HostThreadLock(const HostThreadLock& other) = delete;
HostThreadLock(HostThreadLock&& other) = delete;
HostThreadLock& operator=(const HostThreadLock& other) = delete;
HostThreadLock& operator=(HostThreadLock&& other) = delete;
- void Lock()
- {
- m_lock.lock();
- Core::DeclareAsHostThread();
- }
-
- void Unlock()
- {
- m_lock.unlock();
- Core::UndeclareAsHostThread();
- }
+ void Lock() { m_lock.lock(); }
+
+ void Unlock() { m_lock.unlock(); }
private:
static std::mutex s_host_identity_mutex;