Pare down ThreadSupport and remove ancient thread code.

This patch removes almost all of the existing platform-specific
ThreadSupport code, as well as code derived from it. It is now
implemented on top of C++11 threads and is much simpler.

This is the first inclusion of STL in SourceMod. Mac and Windows are
allowed to dynamically link to their respective implementations. On
Linux, libstdc++ is statically linked, except in the cases where it was
already dynamically linked (csgo, blade).

IEventSignal has been retained because sourcemod-curl-extension relies
on it. As written, it is impossible to use as a condition variable,
because the caller does not have access to the underlying mutex. There
is no way to make this API safe or non-racy, so extensions relying on
it should switch to C++11 threads.

ThreadWorker is now pared down and does not interact or inherit from
BaseWorker in any way. Basic functionality has been tested. Since it is
not used anywhere in SourceMod, or seemingly in any repository on
GitHub, it's unclear whether it should even exist. But it has been
tested in this patch.

This change bumps the minimum macOS version to OS X 10.7, and the
minimum C++ standard level to C++14.
This commit is contained in:
David Anderson
2020-05-13 00:35:29 -07:00
committed by David Anderson
parent 87cc42d348
commit f76cb94511
13 changed files with 534 additions and 943 deletions
+8 -6
View File
@@ -1,5 +1,5 @@
/**
* vim: set ts=4 :
* vim: set ts=4 sw=4 tw=99 noet :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
@@ -273,7 +273,9 @@ namespace SourceMod
};
/**
* @brief Describes a simple "condition variable"/signal lock.
* @brief Object that can be used to signal from one thread to another.
* This should not be used and is deprecated. Use C++11
* std::condition_variable instead, as this version is fundamentally racy.
*/
class IEventSignal
{
@@ -286,7 +288,7 @@ namespace SourceMod
*/
virtual void Wait() =0;
/**
/**
* @brief Triggers the signal and resets the signal after triggering.
*/
virtual void Signal() =0;
@@ -326,7 +328,7 @@ namespace SourceMod
* @return Number of tasks processed.
*/
virtual unsigned int RunFrame() =0;
public:
/**
* @brief Pauses the worker.
*
@@ -446,9 +448,9 @@ namespace SourceMod
virtual void ThreadSleep(unsigned int ms) =0;
/**
* @brief Creates a non-signalled event.
* @brief Deprecated; do not use.
*
* @return A new IEventSignal pointer (must be destroyed).
* @return Returns a new IEventSignal.
*/
virtual IEventSignal *MakeEventSignal() =0;