aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared/Threading/Callback.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/shared/Threading/Callback.h')
-rw-r--r--src/server/shared/Threading/Callback.h43
1 files changed, 20 insertions, 23 deletions
diff --git a/src/server/shared/Threading/Callback.h b/src/server/shared/Threading/Callback.h
index c48546bbf5c..b462fce25d5 100644
--- a/src/server/shared/Threading/Callback.h
+++ b/src/server/shared/Threading/Callback.h
@@ -18,17 +18,14 @@
#ifndef _CALLBACK_H
#define _CALLBACK_H
-#include <ace/Future.h>
-#include <ace/Future_Set.h>
+#include <future>
#include "QueryResult.h"
-typedef ACE_Future<QueryResult> QueryResultFuture;
-typedef ACE_Future<PreparedQueryResult> PreparedQueryResultFuture;
+typedef std::future<QueryResult> QueryResultFuture;
+typedef std::promise<QueryResult> QueryResultPromise;
+typedef std::future<PreparedQueryResult> PreparedQueryResultFuture;
+typedef std::promise<PreparedQueryResult> PreparedQueryResultPromise;
-/*! A simple template using ACE_Future to manage callbacks from the thread and object that
- issued the request. <ParamType> is variable type of parameter that is used as parameter
- for the callback function.
-*/
#define CALLBACK_STAGE_INVALID uint8(-1)
template <typename Result, typename ParamType, bool chain = false>
@@ -38,29 +35,29 @@ class QueryCallback
QueryCallback() : _param(), _stage(chain ? 0 : CALLBACK_STAGE_INVALID) { }
//! The parameter of this function should be a resultset returned from either .AsyncQuery or .AsyncPQuery
- void SetFutureResult(ACE_Future<Result> value)
+ void SetFutureResult(std::future<Result> value)
{
- _result = value;
+ _result = std::move(value);
}
- ACE_Future<Result> GetFutureResult()
+ std::future<Result>& GetFutureResult()
{
return _result;
}
int IsReady()
{
- return _result.ready();
+ return _result.valid() && _result.wait_for(std::chrono::seconds(0)) == std::future_status::ready;
}
void GetResult(Result& res)
{
- _result.get(res);
+ res = _result.get();
}
void FreeResult()
{
- _result.cancel();
+ // Nothing to do here, the constructor of std::future will take care of the cleanup
}
void SetParam(ParamType value)
@@ -106,7 +103,7 @@ class QueryCallback
}
private:
- ACE_Future<Result> _result;
+ std::future<Result> _result;
ParamType _param;
uint8 _stage;
@@ -121,29 +118,29 @@ class QueryCallback_2
QueryCallback_2() : _stage(chain ? 0 : CALLBACK_STAGE_INVALID) { }
//! The parameter of this function should be a resultset returned from either .AsyncQuery or .AsyncPQuery
- void SetFutureResult(ACE_Future<Result> value)
+ void SetFutureResult(std::future<Result> value)
{
- _result = value;
+ _result = std::move(value);
}
- ACE_Future<Result> GetFutureResult()
+ std::future<Result>& GetFutureResult()
{
return _result;
}
int IsReady()
{
- return _result.ready();
+ return _result.valid() && _result.wait_for(std::chrono::seconds(0)) == std::future_status::ready;
}
void GetResult(Result& res)
{
- _result.get(res);
+ res = _result.get();
}
void FreeResult()
{
- _result.cancel();
+ // Nothing to do here, the constructor of std::future will take care of the cleanup
}
void SetFirstParam(ParamType1 value)
@@ -200,7 +197,7 @@ class QueryCallback_2
}
private:
- ACE_Future<Result> _result;
+ std::future<Result> _result;
ParamType1 _param_1;
ParamType2 _param_2;
uint8 _stage;
@@ -209,4 +206,4 @@ class QueryCallback_2
QueryCallback_2& operator=(QueryCallback_2 const& right) = delete;
};
-#endif \ No newline at end of file
+#endif