SPEC-7531 Change Code/CryEngine to Code/Legacy (#1634)
* git mv Code\CryEngine Code\Legacy * redirecting CMakeLists.txt * fixing uic warning * Some more CryEngine mentions * validation scripts Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_CRYCOMMON_SYNCHRONIZATION_H
|
||||
#define CRYINCLUDE_CRYCOMMON_SYNCHRONIZATION_H
|
||||
#pragma once
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Synchronization policies, for classes (e.g. containers, allocators) that may
|
||||
// or may not be multithread-safe.
|
||||
//
|
||||
// Policies should be used as a template argument to such classes,
|
||||
// and these class implementations should then utilise the policy, as a base-class or member.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include "MultiThread.h"
|
||||
#include "CryThread.h"
|
||||
|
||||
namespace stl
|
||||
{
|
||||
template<class Sync>
|
||||
struct AutoLock
|
||||
{
|
||||
ILINE AutoLock(Sync& sync)
|
||||
: _sync(sync)
|
||||
{
|
||||
sync.Lock();
|
||||
}
|
||||
ILINE ~AutoLock()
|
||||
{
|
||||
_sync.Unlock();
|
||||
}
|
||||
|
||||
private:
|
||||
Sync& _sync;
|
||||
};
|
||||
|
||||
|
||||
struct PSyncNone
|
||||
{
|
||||
void Lock() {}
|
||||
void Unlock() {}
|
||||
};
|
||||
|
||||
struct PSyncMultiThread
|
||||
{
|
||||
PSyncMultiThread()
|
||||
: _Semaphore(0) {}
|
||||
|
||||
void Lock()
|
||||
{
|
||||
CryWriteLock(&_Semaphore);
|
||||
}
|
||||
void Unlock()
|
||||
{
|
||||
CryReleaseWriteLock(&_Semaphore);
|
||||
}
|
||||
int IsLocked() const volatile
|
||||
{
|
||||
return _Semaphore;
|
||||
}
|
||||
|
||||
private:
|
||||
volatile int _Semaphore;
|
||||
};
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
struct PSyncDebug
|
||||
: public PSyncMultiThread
|
||||
{
|
||||
void Lock()
|
||||
{
|
||||
assert(!IsLocked());
|
||||
PSyncMultiThread::Lock();
|
||||
}
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
typedef PSyncNone PSyncDebug;
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_CRYCOMMON_SYNCHRONIZATION_H
|
||||
Reference in New Issue
Block a user