/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ // Description : Public include file for the multi-threading API. #pragma once // Include basic multithread primitives. #include "MultiThread.h" #include "BitFiddling.h" #include ////////////////////////////////////////////////////////////////////////// // Lock types: // // CRYLOCK_FAST // A fast potentially (non-recursive) mutex. // CRYLOCK_RECURSIVE // A recursive mutex. ////////////////////////////////////////////////////////////////////////// enum CryLockType { CRYLOCK_FAST = 1, CRYLOCK_RECURSIVE = 2, }; #define CRYLOCK_HAVE_FASTLOCK 1 ///////////////////////////////////////////////////////////////////////////// // // Primitive locks and conditions. // // Primitive locks are represented by instance of class CryLockT // // template class CryLockT { /* Unsupported lock type. */ }; ////////////////////////////////////////////////////////////////////////// // Typedefs. ////////////////////////////////////////////////////////////////////////// typedef CryLockT CryCriticalSection; typedef CryLockT CryCriticalSectionNonRecursive; ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// // // CryAutoCriticalSection implements a helper class to automatically // lock critical section in constructor and release on destructor. // ////////////////////////////////////////////////////////////////////////// template class CryAutoLock { private: LockClass* m_pLock; CryAutoLock(); CryAutoLock(const CryAutoLock&); CryAutoLock& operator = (const CryAutoLock&); public: CryAutoLock(LockClass& Lock) : m_pLock(&Lock) { m_pLock->Lock(); } CryAutoLock(const LockClass& Lock) : m_pLock(const_cast(&Lock)) { m_pLock->Lock(); } ~CryAutoLock() { m_pLock->Unlock(); } }; ////////////////////////////////////////////////////////////////////////// // // Auto critical section is the most commonly used type of auto lock. // ////////////////////////////////////////////////////////////////////////// typedef CryAutoLock CryAutoCriticalSection; /////////////////////////////////////////////////////////////////////////////// // Include architecture specific code. #if AZ_LEGACY_CRYCOMMON_TRAIT_USE_PTHREADS #include #define AZ_RESTRICTED_SECTION_IMPLEMENTED #elif defined(WIN32) || defined(WIN64) #include #define AZ_RESTRICTED_SECTION_IMPLEMENTED #elif defined(AZ_RESTRICTED_PLATFORM) #include AZ_RESTRICTED_FILE(CryThread_h) #endif #if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED) #undef AZ_RESTRICTED_SECTION_IMPLEMENTED #else // Put other platform specific includes here! #endif #if !defined _CRYTHREAD_CONDLOCK_GLITCH typedef CryLockT CryMutex; #endif // !_CRYTHREAD_CONDLOCK_GLITCH // Include all multithreading containers. #include "MultiThread_Containers.h"