TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
TransactionTask Class Reference

#include <Transaction.h>

Public Member Functions

 TransactionTask (SQLTransaction trans)
 
 ~TransactionTask ()
 
- Public Member Functions inherited from SQLOperation
 SQLOperation ()
 
virtual ~SQLOperation ()
 
virtual int call ()
 
virtual void SetConnection (MySQLConnection *con)
 

Protected Member Functions

bool Execute () override
 

Protected Attributes

SQLTransaction m_trans
 

Static Protected Attributes

static std::mutex _deadlockLock
 

Friends

template<class T >
class DatabaseWorkerPool
 
class DatabaseWorker
 

Additional Inherited Members

- Public Attributes inherited from SQLOperation
MySQLConnection * m_conn
 

Detailed Description

Low level class

Constructor & Destructor Documentation

TransactionTask::TransactionTask ( SQLTransaction  trans)
inline
67 : m_trans(trans) { }
SQLTransaction m_trans
Definition: Transaction.h:73
TransactionTask::~TransactionTask ( )
inline
68 { }

Member Function Documentation

bool TransactionTask::Execute ( )
overrideprotectedvirtual

Implements SQLOperation.

68 {
69  int errorCode = m_conn->ExecuteTransaction(m_trans);
70  if (!errorCode)
71  return true;
72 
73  if (errorCode == ER_LOCK_DEADLOCK)
74  {
75  // Make sure only 1 async thread retries a transaction so they don't keep dead-locking each other
76  std::lock_guard<std::mutex> lock(_deadlockLock);
77  uint8 loopBreaker = 5; // Handle MySQL Errno 1213 without extending deadlock to the core itself
78  for (uint8 i = 0; i < loopBreaker; ++i)
79  if (!m_conn->ExecuteTransaction(m_trans))
80  return true;
81  }
82 
83  // Clean up now.
84  m_trans->Cleanup();
85 
86  return false;
87 }
MySQLConnection * m_conn
Definition: SQLOperation.h:70
uint8_t uint8
Definition: Define.h:152
SQLTransaction m_trans
Definition: Transaction.h:73
static std::mutex _deadlockLock
Definition: Transaction.h:74

Friends And Related Function Documentation

friend class DatabaseWorker
friend
template<class T >
friend class DatabaseWorkerPool
friend

Member Data Documentation

std::mutex TransactionTask::_deadlockLock
staticprotected
SQLTransaction TransactionTask::m_trans
protected

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