OregonCore  revision be9e804-git
Your Favourite TBC server
SqlTransaction Class Reference

#include <SqlOperations.h>

+ Inheritance diagram for SqlTransaction:

Classes

struct  QueuedItem
 

Public Member Functions

 ~SqlTransaction ()
 
void DelayExecute (const char *sql)
 
void DelayExecute (PreparedStatement *stmt, PreparedValues &values)
 
void Execute (Database *db)
 
- Public Member Functions inherited from SqlOperation
virtual void OnRemove ()
 
virtual ~SqlOperation ()
 

Protected Attributes

std::queue< QueuedItemqueue
 
ACE_Thread_Mutex mutex
 

Friends

class Database
 

Detailed Description

Definition at line 78 of file SqlOperations.h.

Constructor & Destructor Documentation

SqlTransaction::~SqlTransaction ( )
inline

Definition at line 100 of file SqlOperations.h.

References SqlTransaction::QueuedItem::isStmt, SqlTransaction::QueuedItem::sql, and SqlTransaction::QueuedItem::values.

101  {
102  while (!queue.empty())
103  {
104  QueuedItem item = queue.front();
105  if (!item.isStmt)
106  free (item.sql);
107  else
108  delete item.values;
109  queue.pop();
110  }
111  }
std::queue< QueuedItem > queue
Definition: SqlOperations.h:97

Member Function Documentation

void SqlTransaction::DelayExecute ( const char *  sql)
inline

Definition at line 113 of file SqlOperations.h.

References SqlTransaction::QueuedItem::isStmt, and SqlTransaction::QueuedItem::sql.

114  {
115  QueuedItem item;
116  item.sql = strdup(sql);
117  item.isStmt = false;
118 
119  mutex.acquire();
120  queue.push(item);
121  mutex.release();
122  }
std::queue< QueuedItem > queue
Definition: SqlOperations.h:97
ACE_Thread_Mutex mutex
Definition: SqlOperations.h:98
void SqlTransaction::DelayExecute ( PreparedStatement stmt,
PreparedValues values 
)
inline

Definition at line 123 of file SqlOperations.h.

References SqlTransaction::QueuedItem::isStmt, PreparedValues::size(), SqlTransaction::QueuedItem::stmt, and SqlTransaction::QueuedItem::values.

124  {
125  QueuedItem item;
126  item.stmt = stmt;
127  item.values = new PreparedValues(values.size());
128  *item.values = values;
129  item.isStmt = true;
130 
131  mutex.acquire();
132  queue.push(item);
133  mutex.release();
134  }
std::queue< QueuedItem > queue
Definition: SqlOperations.h:97
ACE_Thread_Mutex mutex
Definition: SqlOperations.h:98
size_t size() const
void SqlTransaction::Execute ( Database db)
inlinevirtual

Implements SqlOperation.

Definition at line 135 of file SqlOperations.h.

References Database::ExecuteTransaction().

136  {
137  db->ExecuteTransaction(this);
138  }
bool ExecuteTransaction(SqlTransaction *transaction)
Atomically executed SqlTransaction. Don&#39;t call this directly, use BeginTransaction and CommitTransact...
Definition: Database.cpp:593

Friends And Related Function Documentation

friend class Database
friend

Definition at line 81 of file SqlOperations.h.

Member Data Documentation

ACE_Thread_Mutex SqlTransaction::mutex
protected

Definition at line 98 of file SqlOperations.h.

Referenced by Database::ExecuteTransaction().

std::queue<QueuedItem> SqlTransaction::queue
protected

Definition at line 97 of file SqlOperations.h.

Referenced by Database::ExecuteTransaction().


The documentation for this class was generated from the following file: