Reimplement ACE_Based::LockedQueue as SQL holder for the SqlTransaction class, since std::queue is not safe when multiple threads are reading/writing to it at the same time (SqlDelayThread and a MapUpdate Thread).

Original patch by thenecromancer, was removed for ungrounded reasons.
Thanks to Zor for the insight.
Please give feedback on how this affects mtmaps usage.

--HG--
branch : trunk
This commit is contained in:
Machiavelli
2010-05-15 14:58:16 +02:00
parent 7ff9e82f1a
commit fa57ce4cd1
2 changed files with 7 additions and 11 deletions

View File

@@ -57,11 +57,12 @@ class SqlStatement : public SqlOperation
class SqlTransaction : public SqlOperation
{
typedef ACE_Based::LockedQueue<const char *, ACE_Thread_Mutex> LockedQueue;
private:
std::queue<const char *> m_queue;
LockedQueue m_queue;
public:
SqlTransaction() {}
void DelayExecute(const char *sql) { m_queue.push(strdup(sql)); }
void DelayExecute(const char *sql) { m_queue.add(strdup(sql)); }
void Execute(Database *db);
};