|
Project SkyFire Core
SkyFire 5.4.8 server core API documentation
|
#include <DatabaseWorkerPool.h>
Public Member Functions | |
| QueryResultFuture | AsyncPQuery (const char *sql,...) |
| QueryResultFuture | AsyncQuery (const char *sql) |
| PreparedQueryResultFuture | AsyncQuery (PreparedStatement *stmt) |
| SQLTransaction | BeginTransaction () |
| Begins an automanaged transaction pointer that will automatically rollback if not commited. (Autocommit=0). | |
| void | Close () |
| void | CommitTransaction (SQLTransaction transaction) |
| DatabaseWorkerPool () | |
| QueryResultHolderFuture | DelayQueryHolder (SQLQueryHolder *holder) |
| void | DirectCommitTransaction (SQLTransaction &transaction) |
| void | DirectExecute (const char *sql) |
| void | DirectExecute (PreparedStatement *stmt) |
| void | DirectPExecute (const char *sql,...) |
| void | EscapeString (std::string &str) |
| Apply escape string'ing for current collation. (utf8). | |
| void | Execute (const char *sql) |
| void | Execute (PreparedStatement *stmt) |
| void | ExecuteOrAppend (SQLTransaction &trans, const char *sql) |
| void | ExecuteOrAppend (SQLTransaction &trans, PreparedStatement *stmt) |
| PreparedStatement * | GetPreparedStatement (uint32 index) |
| void | KeepAlive () |
| Keeps all our MySQL connections alive, prevent the server from disconnecting us. | |
| bool | Open (const char *host, const char *port, const char *user, const char *password, const char *database, uint8 async_threads, uint8 synch_threads) |
| bool | Open (const std::string &infoString, uint8 async_threads, uint8 synch_threads) |
| void | PExecute (const char *sql,...) |
| QueryResult | PQuery (const char *sql, T *conn,...) |
| QueryResult | PQuery (const char *sql,...) |
| QueryResult | Query (const char *sql, T *conn=NULL) |
| PreparedQueryResult | Query (PreparedStatement *stmt) |
| void | Wait () |
| Blocks until all currently queued asynchronous operations have finished. | |
| ~DatabaseWorkerPool () | |
Private Types | |
| enum | _internalIndex { IDX_ASYNC , IDX_SYNCH , IDX_SIZE } |
Private Member Functions | |
| void | Enqueue (SQLOperation *op) |
| unsigned long | EscapeString (char *to, const char *from, unsigned long length) |
| char const * | GetDatabaseName () const |
| T * | GetFreeConnection () |
Private Attributes | |
| uint32 | _connectionCount [2] |
| MySQLConnectionInfo * | _connectionInfo |
| Counter of MySQL connections;. | |
| std::vector< std::vector< T * > > | _connections |
| Queue shared by async worker threads. | |
| Skyfire::DatabaseQueue * | _queue |
Definition at line 35 of file DatabaseWorkerPool.h.
|
private |
| Enumerator | |
|---|---|
| IDX_ASYNC | |
| IDX_SYNCH | |
| IDX_SIZE | |
Definition at line 546 of file DatabaseWorkerPool.h.
|
inline |
Definition at line 39 of file DatabaseWorkerPool.h.
|
inline |
Definition at line 48 of file DatabaseWorkerPool.h.
|
inline |
Enqueues a query in string format -with variable args- that will set the value of the QueryResultFuture return object as soon as the query is executed. The return value is then processed in ProcessQueryCallback methods.
Definition at line 339 of file DatabaseWorkerPool.h.
|
inline |
Asynchronous query (with resultset) methods.
Enqueues a query in string format that will set the value of the QueryResultFuture return object as soon as the query is executed. The return value is then processed in ProcessQueryCallback methods.
Actual return value has no use yet
Definition at line 329 of file DatabaseWorkerPool.h.
Referenced by DatabaseWorkerPool< CharacterDatabaseConnection >::AsyncPQuery().
|
inline |
Enqueues a query in prepared format that will set the value of the PreparedQueryResultFuture return object as soon as the query is executed. The return value is then processed in ProcessQueryCallback methods. Statement must be prepared with CONNECTION_ASYNC flag.
Definition at line 353 of file DatabaseWorkerPool.h.
|
inline |
Begins an automanaged transaction pointer that will automatically rollback if not commited. (Autocommit=0).
Transaction context methods.
Definition at line 378 of file DatabaseWorkerPool.h.
|
inline |
Shuts down delaythreads for this connection pool. The next dequeue attempt in worker thread tasks will end the worker thread task.
Block until no more threads are running this task.
Closes the actualy MySQL connection.
Shut down the synchronous connections There's no need for locking the connection, because DatabaseWorkerPool<>::Close should only be called after any other thread tasks in the core have exited, meaning there can be no concurrent access at this point.
Definition at line 130 of file DatabaseWorkerPool.h.
Referenced by DatabaseWorkerPool< CharacterDatabaseConnection >::Close().
|
inline |
Enqueues a collection of one-way SQL operations (can be both adhoc and prepared). The order in which these operations were appended to the transaction will be respected during execution.
Definition at line 385 of file DatabaseWorkerPool.h.
|
inline |
Enqueues a vector of SQL operations (can be both adhoc and prepared) that will set the value of the QueryResultHolderFuture return object as soon as the query is executed. The return value is then processed in ProcessQueryCallback methods. Any prepared statements added to this holder need to be prepared with the CONNECTION_ASYNC flag.
Fool compiler, has no use yet
Definition at line 365 of file DatabaseWorkerPool.h.
|
inline |
Directly executes a collection of one-way SQL operations (can be both adhoc and prepared). The order in which these operations were appended to the transaction will be respected during execution.
Handle MySQL Errno 1213 without extending deadlock to the core itself
Clean up now.
Definition at line 415 of file DatabaseWorkerPool.h.
|
inline |
Direct synchronous one-way statement methods.
Directly executes a one-way SQL operation in string format, that will block the calling thread until finished. This method should only be used for queries that are only executed once, e.g during startup.
Definition at line 209 of file DatabaseWorkerPool.h.
Referenced by DatabaseWorkerPool< CharacterDatabaseConnection >::DirectPExecute().
|
inline |
Directly executes a one-way SQL operation in prepared statement format, that will block the calling thread until finished. Statement must be prepared with the CONNECTION_SYNCH flag.
Delete proxy-class. Not needed anymore
Definition at line 237 of file DatabaseWorkerPool.h.
|
inline |
Directly executes a one-way SQL operation in string format -with variable args-, that will block the calling thread until finished. This method should only be used for queries that are only executed once, e.g during startup.
Definition at line 221 of file DatabaseWorkerPool.h.
|
inlineprivate |
Definition at line 516 of file DatabaseWorkerPool.h.
Referenced by DatabaseWorkerPool< CharacterDatabaseConnection >::AsyncQuery(), DatabaseWorkerPool< CharacterDatabaseConnection >::AsyncQuery(), DatabaseWorkerPool< CharacterDatabaseConnection >::CommitTransaction(), DatabaseWorkerPool< CharacterDatabaseConnection >::DelayQueryHolder(), DatabaseWorkerPool< CharacterDatabaseConnection >::Execute(), DatabaseWorkerPool< CharacterDatabaseConnection >::Execute(), and DatabaseWorkerPool< CharacterDatabaseConnection >::KeepAlive().
|
inlineprivate |
Definition at line 508 of file DatabaseWorkerPool.h.
|
inline |
Apply escape string'ing for current collation. (utf8).
Definition at line 475 of file DatabaseWorkerPool.h.
Referenced by DatabaseWorkerPool< CharacterDatabaseConnection >::EscapeString().
|
inline |
Delayed one-way statement methods.
Enqueues a one-way SQL operation in string format that will be executed asynchronously. This method should only be used for queries that are only executed once, e.g during startup.
Definition at line 170 of file DatabaseWorkerPool.h.
Referenced by DatabaseWorkerPool< CharacterDatabaseConnection >::ExecuteOrAppend(), DatabaseWorkerPool< CharacterDatabaseConnection >::ExecuteOrAppend(), and DatabaseWorkerPool< CharacterDatabaseConnection >::PExecute().
|
inline |
Enqueues a one-way SQL operation in prepared statement format that will be executed asynchronously. Statement must be prepared with CONNECTION_ASYNC flag.
Definition at line 197 of file DatabaseWorkerPool.h.
|
inline |
Method used to execute ad-hoc statements in a diverse context. Will be wrapped in a transaction if valid object is present, otherwise executed standalone.
Definition at line 454 of file DatabaseWorkerPool.h.
|
inline |
Method used to execute prepared statements in a diverse context. Will be wrapped in a transaction if valid object is present, otherwise executed standalone.
Definition at line 444 of file DatabaseWorkerPool.h.
|
inlineprivate |
Definition at line 540 of file DatabaseWorkerPool.h.
Referenced by DatabaseWorkerPool< CharacterDatabaseConnection >::Close(), DatabaseWorkerPool< CharacterDatabaseConnection >::Open(), and DatabaseWorkerPool< CharacterDatabaseConnection >::Open().
|
inlineprivate |
Gets a free connection in the synchronous connection pool. Caller MUST call t->Unlock() after touching the MySQL context to prevent deadlocks.
Block forever until a connection is free
Must be matched with t->Unlock() or you will get deadlocks
Definition at line 523 of file DatabaseWorkerPool.h.
Referenced by DatabaseWorkerPool< CharacterDatabaseConnection >::DirectCommitTransaction(), DatabaseWorkerPool< CharacterDatabaseConnection >::DirectExecute(), DatabaseWorkerPool< CharacterDatabaseConnection >::DirectExecute(), DatabaseWorkerPool< CharacterDatabaseConnection >::Query(), and DatabaseWorkerPool< CharacterDatabaseConnection >::Query().
|
inline |
Other
Automanaged (internally) pointer to a prepared statement object for usage in upper level code. Pointer is deleted in this->DirectExecute(PreparedStatement*), this->Query(PreparedStatement*) or PreparedStatementTask::~PreparedStatementTask. This object is not tied to the prepared statement on the MySQL context yet until execution.
Definition at line 469 of file DatabaseWorkerPool.h.
|
inline |
Keeps all our MySQL connections alive, prevent the server from disconnecting us.
Ping synchronous connections
Assuming all worker threads are free, every worker thread will receive 1 ping operation request If one or more worker threads are busy, the ping operations will not be split evenly, but this doesn't matter as the sole purpose is to prevent connections from idling.
Definition at line 487 of file DatabaseWorkerPool.h.
|
inline |
Open asynchronous connections (delayed operations)
Open synchronous connections (direct, blocking operations)
Definition at line 52 of file DatabaseWorkerPool.h.
|
inline |
Open asynchronous connections (delayed operations)
Open synchronous connections (direct, blocking operations)
Definition at line 91 of file DatabaseWorkerPool.h.
|
inline |
Enqueues a one-way SQL operation in string format -with variable args- that will be executed asynchronously. This method should only be used for queries that are only executed once, e.g during startup.
Definition at line 181 of file DatabaseWorkerPool.h.
|
inline |
Directly executes an SQL query in string format -with variable args- that will block the calling thread until finished. Returns reference counted auto pointer, no need for manual memory management in upper level code.
Definition at line 272 of file DatabaseWorkerPool.h.
|
inline |
Directly executes an SQL query in string format -with variable args- that will block the calling thread until finished. Returns reference counted auto pointer, no need for manual memory management in upper level code.
Definition at line 288 of file DatabaseWorkerPool.h.
|
inline |
Synchronous query (with resultset) methods.
Directly executes an SQL query in string format that will block the calling thread until finished. Returns reference counted auto pointer, no need for manual memory management in upper level code.
Definition at line 253 of file DatabaseWorkerPool.h.
Referenced by DatabaseWorkerPool< CharacterDatabaseConnection >::PQuery(), and DatabaseWorkerPool< CharacterDatabaseConnection >::PQuery().
|
inline |
Directly executes an SQL query in prepared format that will block the calling thread until finished. Returns reference counted auto pointer, no need for manual memory management in upper level code. Statement must be prepared with CONNECTION_SYNCH flag.
Delete proxy-class. Not needed anymore
Definition at line 305 of file DatabaseWorkerPool.h.
|
inline |
Blocks until all currently queued asynchronous operations have finished.
Definition at line 408 of file DatabaseWorkerPool.h.
|
private |
Definition at line 555 of file DatabaseWorkerPool.h.
|
private |
Counter of MySQL connections;.
Definition at line 556 of file DatabaseWorkerPool.h.
|
private |
Queue shared by async worker threads.
Definition at line 554 of file DatabaseWorkerPool.h.
|
private |
Definition at line 553 of file DatabaseWorkerPool.h.