mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 01:37:37 +01:00
Core/Database: Remove future/promise typedefs from a public header (these are internal to database project)
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
#ifndef DatabaseEnvFwd_h__
|
||||
#define DatabaseEnvFwd_h__
|
||||
|
||||
#include <future>
|
||||
#include <memory>
|
||||
|
||||
struct QueryResultFieldMetadata;
|
||||
@@ -26,8 +25,6 @@ class Field;
|
||||
|
||||
class ResultSet;
|
||||
using QueryResult = std::shared_ptr<ResultSet>;
|
||||
using QueryResultFuture = std::future<QueryResult>;
|
||||
using QueryResultPromise = std::promise<QueryResult>;
|
||||
|
||||
class CharacterDatabaseConnection;
|
||||
class HotfixDatabaseConnection;
|
||||
@@ -46,8 +43,6 @@ using WorldDatabasePreparedStatement = PreparedStatement<WorldDatabaseConnection
|
||||
|
||||
class PreparedResultSet;
|
||||
using PreparedQueryResult = std::shared_ptr<PreparedResultSet>;
|
||||
using PreparedQueryResultFuture = std::future<PreparedQueryResult>;
|
||||
using PreparedQueryResultPromise = std::promise<PreparedQueryResult>;
|
||||
|
||||
class QueryCallback;
|
||||
|
||||
@@ -58,9 +53,6 @@ using QueryCallbackProcessor = AsyncCallbackProcessor<QueryCallback>;
|
||||
|
||||
class TransactionBase;
|
||||
|
||||
using TransactionFuture = std::future<bool>;
|
||||
using TransactionPromise = std::promise<bool>;
|
||||
|
||||
template<typename T>
|
||||
class Transaction;
|
||||
|
||||
@@ -75,8 +67,6 @@ using LoginDatabaseTransaction = SQLTransaction<LoginDatabaseConnection>;
|
||||
using WorldDatabaseTransaction = SQLTransaction<WorldDatabaseConnection>;
|
||||
|
||||
class SQLQueryHolderBase;
|
||||
using QueryResultHolderFuture = std::future<void>;
|
||||
using QueryResultHolderPromise = std::promise<void>;
|
||||
|
||||
template<typename T>
|
||||
class SQLQueryHolder;
|
||||
|
||||
@@ -260,7 +260,7 @@ PreparedQueryResult DatabaseWorkerPool<T>::Query(PreparedStatement<T>* stmt)
|
||||
template <class T>
|
||||
QueryCallback DatabaseWorkerPool<T>::AsyncQuery(char const* sql)
|
||||
{
|
||||
QueryResultFuture result = boost::asio::post(_ioContext->get_executor(), boost::asio::use_future([this, sql = std::string(sql), tracker = QueueSizeTracker(this)]
|
||||
std::future<QueryResult> result = boost::asio::post(_ioContext->get_executor(), boost::asio::use_future([this, sql = std::string(sql), tracker = QueueSizeTracker(this)]
|
||||
{
|
||||
T* conn = GetAsyncConnectionForCurrentThread();
|
||||
return BasicStatementTask::Query(conn, sql.c_str());
|
||||
@@ -271,7 +271,7 @@ QueryCallback DatabaseWorkerPool<T>::AsyncQuery(char const* sql)
|
||||
template <class T>
|
||||
QueryCallback DatabaseWorkerPool<T>::AsyncQuery(PreparedStatement<T>* stmt)
|
||||
{
|
||||
PreparedQueryResultFuture result = boost::asio::post(_ioContext->get_executor(), boost::asio::use_future([this, stmt = std::unique_ptr<PreparedStatement<T>>(stmt), tracker = QueueSizeTracker(this)]
|
||||
std::future<PreparedQueryResult> result = boost::asio::post(_ioContext->get_executor(), boost::asio::use_future([this, stmt = std::unique_ptr<PreparedStatement<T>>(stmt), tracker = QueueSizeTracker(this)]
|
||||
{
|
||||
T* conn = GetAsyncConnectionForCurrentThread();
|
||||
return PreparedStatementTask::Query(conn, stmt.get());
|
||||
@@ -282,7 +282,7 @@ QueryCallback DatabaseWorkerPool<T>::AsyncQuery(PreparedStatement<T>* stmt)
|
||||
template <class T>
|
||||
SQLQueryHolderCallback DatabaseWorkerPool<T>::DelayQueryHolder(std::shared_ptr<SQLQueryHolder<T>> holder)
|
||||
{
|
||||
QueryResultHolderFuture result = boost::asio::post(_ioContext->get_executor(), boost::asio::use_future([this, holder, tracker = QueueSizeTracker(this)]
|
||||
std::future<void> result = boost::asio::post(_ioContext->get_executor(), boost::asio::use_future([this, holder, tracker = QueueSizeTracker(this)]
|
||||
{
|
||||
T* conn = GetAsyncConnectionForCurrentThread();
|
||||
SQLQueryHolderTask::Execute(conn, holder.get());
|
||||
@@ -343,7 +343,7 @@ TransactionCallback DatabaseWorkerPool<T>::AsyncCommitTransaction(SQLTransaction
|
||||
}
|
||||
#endif // TRINITY_DEBUG
|
||||
|
||||
TransactionFuture result = boost::asio::post(_ioContext->get_executor(), boost::asio::use_future([this, transaction, tracker = QueueSizeTracker(this)]
|
||||
std::future<bool> result = boost::asio::post(_ioContext->get_executor(), boost::asio::use_future([this, transaction, tracker = QueueSizeTracker(this)]
|
||||
{
|
||||
T* conn = GetAsyncConnectionForCurrentThread();
|
||||
return TransactionTask::Execute(conn, transaction);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "DatabaseEnvFwd.h"
|
||||
#include "StringFormat.h"
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
class MySQLPreparedStatement;
|
||||
|
||||
@@ -200,7 +200,7 @@ bool QueryCallback::InvokeIfReady()
|
||||
{
|
||||
if (_string.valid() && _string.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
|
||||
{
|
||||
QueryResultFuture f(std::move(_string));
|
||||
std::future<QueryResult> f(std::move(_string));
|
||||
std::function<void(QueryCallback&, QueryResult)> cb(std::move(callback._string));
|
||||
cb(*this, f.get());
|
||||
return checkStateAndReturnCompletion();
|
||||
@@ -210,7 +210,7 @@ bool QueryCallback::InvokeIfReady()
|
||||
{
|
||||
if (_prepared.valid() && _prepared.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
|
||||
{
|
||||
PreparedQueryResultFuture f(std::move(_prepared));
|
||||
std::future<PreparedQueryResult> f(std::move(_prepared));
|
||||
std::function<void(QueryCallback&, PreparedQueryResult)> cb(std::move(callback._prepared));
|
||||
cb(*this, f.get());
|
||||
return checkStateAndReturnCompletion();
|
||||
|
||||
@@ -21,14 +21,15 @@
|
||||
#include "DatabaseEnvFwd.h"
|
||||
#include "Define.h"
|
||||
#include <functional>
|
||||
#include <future>
|
||||
#include <list>
|
||||
#include <queue>
|
||||
|
||||
class TC_DATABASE_API QueryCallback
|
||||
{
|
||||
public:
|
||||
explicit QueryCallback(QueryResultFuture&& result);
|
||||
explicit QueryCallback(PreparedQueryResultFuture&& result);
|
||||
explicit QueryCallback(std::future<QueryResult>&& result);
|
||||
explicit QueryCallback(std::future<PreparedQueryResult>&& result);
|
||||
QueryCallback(QueryCallback&& right) noexcept;
|
||||
QueryCallback& operator=(QueryCallback&& right) noexcept;
|
||||
~QueryCallback();
|
||||
@@ -55,8 +56,8 @@ private:
|
||||
|
||||
union
|
||||
{
|
||||
QueryResultFuture _string;
|
||||
PreparedQueryResultFuture _prepared;
|
||||
std::future<QueryResult> _string;
|
||||
std::future<PreparedQueryResult> _prepared;
|
||||
};
|
||||
bool _isPrepared;
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "Define.h"
|
||||
#include "DatabaseEnvFwd.h"
|
||||
#include <future>
|
||||
#include <vector>
|
||||
|
||||
class MySQLConnection;
|
||||
@@ -59,7 +60,7 @@ public:
|
||||
class TC_DATABASE_API SQLQueryHolderCallback
|
||||
{
|
||||
public:
|
||||
SQLQueryHolderCallback(std::shared_ptr<SQLQueryHolderBase>&& holder, QueryResultHolderFuture&& future)
|
||||
SQLQueryHolderCallback(std::shared_ptr<SQLQueryHolderBase>&& holder, std::future<void>&& future)
|
||||
: m_holder(std::move(holder)), m_future(std::move(future)) { }
|
||||
|
||||
SQLQueryHolderCallback(SQLQueryHolderCallback&&) = default;
|
||||
@@ -74,7 +75,7 @@ public:
|
||||
bool InvokeIfReady();
|
||||
|
||||
std::shared_ptr<SQLQueryHolderBase> m_holder;
|
||||
QueryResultHolderFuture m_future;
|
||||
std::future<void> m_future;
|
||||
std::function<void(SQLQueryHolderBase const&)> m_callback;
|
||||
};
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "DatabaseEnvFwd.h"
|
||||
#include "StringFormat.h"
|
||||
#include <functional>
|
||||
#include <future>
|
||||
#include <mutex>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
@@ -100,7 +101,7 @@ private:
|
||||
class TC_DATABASE_API TransactionCallback
|
||||
{
|
||||
public:
|
||||
TransactionCallback(TransactionFuture&& future) : m_future(std::move(future)) { }
|
||||
TransactionCallback(std::future<bool>&& future) : m_future(std::move(future)) { }
|
||||
TransactionCallback(TransactionCallback&&) = default;
|
||||
|
||||
TransactionCallback& operator=(TransactionCallback&&) = default;
|
||||
@@ -112,7 +113,7 @@ public:
|
||||
|
||||
bool InvokeIfReady();
|
||||
|
||||
TransactionFuture m_future;
|
||||
std::future<bool> m_future;
|
||||
std::function<void(bool)> m_callback;
|
||||
};
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "Define.h"
|
||||
#include "DatabaseEnvFwd.h"
|
||||
#include <functional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#define _ACCMGR_H
|
||||
|
||||
#include "RBAC.h"
|
||||
#include <functional>
|
||||
|
||||
enum class AccountOpResult : uint8
|
||||
{
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "Pet.h"
|
||||
#include "Player.h"
|
||||
#include "Transport.h"
|
||||
#include <mutex>
|
||||
|
||||
template<class T>
|
||||
void HashMapHolder<T>::Insert(T* o)
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "Trainer.h"
|
||||
#include "VehicleDefines.h"
|
||||
#include "UniqueTrackablePtr.h"
|
||||
#include <atomic>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "SharedDefines.h"
|
||||
#include <boost/circular_buffer_fwd.hpp>
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
Reference in New Issue
Block a user