mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
* All libraries have been isolated from each other, and build into separate artifacts. * Project has been restructured to support isolating libraries. * CCrashHandler now calls a callback on crash (setup from core/dllmain.cpp, this can be setup in any way for any project. This callback is getting called when the apllication crashes. Useful for flushing buffers before closing handles to logging files for example). * Tier0 'CoreMsgV' function now calls a callback sink, which could be set by the user (currently setup to the SDK's internal logger in core/dllmain.cpp). TODO: * Add a batch file to autogenerate all projects. * Add support for dedicated server. * Add support for client dll. Bugs: * Game crashes on the title screen after the UI script compiler has finished (root cause unknown). * Curl error messages are getting logged twice for the dedicated server due to the removal of all "DEDICATED" preprocessor directives to support isolating projects. This has to be fixed properly!
63 lines
1.5 KiB
C++
63 lines
1.5 KiB
C++
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||
//
|
||
// Purpose: Thread tools
|
||
//
|
||
// $Workfile: $
|
||
// $NoKeywords: $
|
||
//===========================================================================//
|
||
|
||
#include "tier0_pch.h"
|
||
#include "tier0/threadtools.h"
|
||
|
||
int32 ThreadInterlockedCompareExchange(LONG volatile* pDest, int32 value, int32 comperand)
|
||
{
|
||
return _InterlockedCompareExchange(pDest, comperand, value);
|
||
}
|
||
|
||
bool ThreadInterlockedAssignIf(LONG volatile* p, int32 value, int32 comperand)
|
||
{
|
||
Assert((size_t)p % 4 == 0);
|
||
return _InterlockedCompareExchange(p, comperand, value);
|
||
}
|
||
|
||
int64 ThreadInterlockedCompareExchange64(int64 volatile* pDest, int64 value, int64 comperand)
|
||
{
|
||
return _InterlockedCompareExchange64(pDest, comperand, value);
|
||
}
|
||
|
||
bool ThreadInterlockedAssignIf64(int64 volatile* pDest, int64 value, int64 comperand)
|
||
{
|
||
return _InterlockedCompareExchange64(pDest, comperand, value);
|
||
}
|
||
|
||
bool ThreadInMainThread()
|
||
{
|
||
return (ThreadGetCurrentId() == (*g_ThreadMainThreadID));
|
||
}
|
||
|
||
bool ThreadInRenderThread()
|
||
{
|
||
return (ThreadGetCurrentId() == g_ThreadRenderThreadID);
|
||
}
|
||
|
||
bool ThreadInServerFrameThread()
|
||
{
|
||
return (ThreadGetCurrentId() == (*g_ThreadServerFrameThreadID));
|
||
}
|
||
|
||
ThreadId_t ThreadGetCurrentId()
|
||
{
|
||
#ifdef _WIN32
|
||
return GetCurrentThreadId();
|
||
#elif defined( _PS3 )
|
||
sys_ppu_thread_t th = 0;
|
||
sys_ppu_thread_get_id(&th);
|
||
return th;
|
||
#elif defined(POSIX)
|
||
return (ThreadId_t)pthread_self();
|
||
#else
|
||
Assert(0);
|
||
DebuggerBreak();
|
||
return 0;
|
||
#endif
|
||
} |