Replace all uses of AMTL threads with STL threads.
This also rewrites the work loop for threaded queries. It has been simplified significantly.
This commit is contained in:
@@ -64,17 +64,13 @@ const char *SqDatabase::GetError(int *errorCode/* =NULL */)
|
||||
|
||||
bool SqDatabase::LockForFullAtomicOperation()
|
||||
{
|
||||
if (!m_FullLock)
|
||||
m_FullLock = new ke::Mutex();
|
||||
|
||||
m_FullLock->Lock();
|
||||
m_FullLock.lock();
|
||||
return true;
|
||||
}
|
||||
|
||||
void SqDatabase::UnlockFromFullAtomicOperation()
|
||||
{
|
||||
if (m_FullLock)
|
||||
m_FullLock->Unlock();
|
||||
m_FullLock.unlock();
|
||||
}
|
||||
|
||||
IDBDriver *SqDatabase::GetDriver()
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#define _INCLUDE_SQLITE_SOURCEMOD_DATABASE_H_
|
||||
|
||||
#include <am-refcounting-threadsafe.h>
|
||||
#include <am-thread-utils.h>
|
||||
#include <mutex>
|
||||
#include "SqDriver.h"
|
||||
|
||||
class SqDatabase
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
}
|
||||
private:
|
||||
sqlite3 *m_sq3;
|
||||
ke::AutoPtr<ke::Mutex> m_FullLock;
|
||||
std::mutex m_FullLock;
|
||||
bool m_Persistent;
|
||||
String m_LastError;
|
||||
int m_LastErrorCode;
|
||||
|
||||
@@ -75,7 +75,7 @@ SqDriver::SqDriver()
|
||||
// of g_SqDriver in SqDatabase's destructor.
|
||||
SqDriver::~SqDriver()
|
||||
{
|
||||
ke::AutoLock lock(&m_OpenLock);
|
||||
std::lock_guard<std::mutex> lock(m_OpenLock);
|
||||
|
||||
List<SqDbInfo>::iterator iter;
|
||||
SqDatabase *sqdb;
|
||||
@@ -178,7 +178,7 @@ inline bool IsPathSepChar(char c)
|
||||
|
||||
IDatabase *SqDriver::Connect(const DatabaseInfo *info, bool persistent, char *error, size_t maxlength)
|
||||
{
|
||||
ke::AutoLock lock(&m_OpenLock);
|
||||
std::lock_guard<std::mutex> lock(m_OpenLock);
|
||||
|
||||
/* Full path to the database file */
|
||||
char fullpath[PLATFORM_MAX_PATH];
|
||||
@@ -296,7 +296,7 @@ IDatabase *SqDriver::Connect(const DatabaseInfo *info, bool persistent, char *er
|
||||
|
||||
void SqDriver::RemovePersistent(IDatabase *pdb)
|
||||
{
|
||||
ke::AutoLock lock(&m_OpenLock);
|
||||
std::lock_guard<std::mutex> lock(m_OpenLock);
|
||||
|
||||
List<SqDbInfo>::iterator iter;
|
||||
for (iter = m_Cache.begin(); iter != m_Cache.end(); iter++)
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <IDBDriver.h>
|
||||
#include <sh_list.h>
|
||||
#include <sh_string.h>
|
||||
#include <am-thread-utils.h>
|
||||
#include <mutex>
|
||||
#include "sqlite-source/sqlite3.h"
|
||||
|
||||
using namespace SourceMod;
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
void RemovePersistent(IDatabase *pdb);
|
||||
private:
|
||||
Handle_t m_Handle;
|
||||
ke::Mutex m_OpenLock;
|
||||
std::mutex m_OpenLock;
|
||||
List<SqDbInfo> m_Cache;
|
||||
bool m_bThreadSafe;
|
||||
bool m_bShutdown;
|
||||
|
||||
Reference in New Issue
Block a user