mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
DirtySDK (EA's Dirty Sockets library) will be used for the LiveAPI implementation, and depends on: EABase, EAThread.
76 lines
1.5 KiB
C++
76 lines
1.5 KiB
C++
///////////////////////////////////////////////////////////////////////////////
|
|
// Copyright (c) Electronic Arts Inc. All rights reserved.
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "TestThread.h"
|
|
#include <EATest/EATest.h>
|
|
#include <eathread/eathread_spinlock.h>
|
|
|
|
|
|
using namespace EA::Thread;
|
|
|
|
|
|
int TestThreadSpinLock()
|
|
{
|
|
int nErrorCount(0);
|
|
|
|
{ // SpinLock -- Basic single-threaded test.
|
|
|
|
SpinLock spinLock;
|
|
|
|
EATEST_VERIFY_MSG(!spinLock.IsLocked(), "SpinLock failure");
|
|
|
|
spinLock.Lock();
|
|
EATEST_VERIFY_MSG(spinLock.IsLocked(), "SpinLock failure");
|
|
|
|
EATEST_VERIFY_MSG(!spinLock.TryLock(), "SpinLock failure");
|
|
|
|
spinLock.Unlock();
|
|
EATEST_VERIFY_MSG(!spinLock.IsLocked(), "SpinLock failure");
|
|
|
|
EATEST_VERIFY_MSG(spinLock.TryLock(), "SpinLock failure");
|
|
EATEST_VERIFY_MSG(spinLock.IsLocked(), "SpinLock failure");
|
|
|
|
spinLock.Unlock();
|
|
EATEST_VERIFY_MSG(!spinLock.IsLocked(), "SpinLock failure");
|
|
}
|
|
|
|
|
|
{ // AutoSpinLock -- Basic single-threaded test.
|
|
|
|
SpinLock spinLock;
|
|
|
|
EATEST_VERIFY_MSG(!spinLock.IsLocked(), "AutoSpinLock failure");
|
|
|
|
{ //Special scope just for the AutoSpinLock
|
|
AutoSpinLock autoSpinLock(spinLock);
|
|
|
|
EATEST_VERIFY_MSG(spinLock.IsLocked(), "AutoSpinLock failure");
|
|
}
|
|
|
|
EATEST_VERIFY_MSG(!spinLock.IsLocked(), "AutoSpinLock failure");
|
|
}
|
|
|
|
|
|
#if EA_THREADS_AVAILABLE
|
|
{ // Multithreaded test
|
|
|
|
// Implement this when we get the thread class working.
|
|
// gTestLengthSeconds;
|
|
}
|
|
#endif
|
|
|
|
return nErrorCount;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|