// License: Modified MIT (NON-AI) // See the LICENSE file in the root directory for license information. // Copyright 2025 Timothy Prepscius #pragma once #include #include "Lock.h" #include "../system/Debug.h" #include #include "../types/Types.h" namespace tjp::core { #ifdef _DEBUG #define USE_REAL_TEST_MUTEX #endif #ifdef USE_REAL_TEST_MUTEX struct TestMutex { struct Lock; using V = size_t; std::atomic v = 0; std::atomic c = 0; Lock lock_of(); u64 get_thread_id() const; void lock(); void unlock(); bool locked_by_caller() const; } ; struct TestMutex::Lock { TestMutex *m = nullptr; u64 id; Lock (); Lock (TestMutex::Lock &&rhs); Lock (TestMutex &m_); ~Lock (); }; #else struct TestMutex { struct Lock { // avoids the unused variable warning ~Lock() {} }; void lock () {} void unlock () {} Lock lock_of () { return TestMutex::Lock {}; } bool locked_by_caller() { return true; } }; #endif } // namespace #include "TestMutex.inl"