diff options
author | Shauren <shauren.trinity@gmail.com> | 2017-01-12 19:40:33 +0100 |
---|---|---|
committer | ariel- <ariel-@users.noreply.github.com> | 2017-01-25 23:38:10 -0300 |
commit | 8af3cccc83aa7fbda348a784e36f45331c091c9a (patch) | |
tree | 89e6bad3b6fe03b9199ecba661ba253f2f444da5 /src/server/database/Database/QueryCallback.h | |
parent | b879a6cae5e31ef382a5b52fa19a726a061e9aca (diff) |
Core/DBLayer: Refine new query callback for chaining
(cherry picked from commit 73e61fa652d1233bfff1db91fa2bca8c317c8caf)
Diffstat (limited to 'src/server/database/Database/QueryCallback.h')
-rw-r--r-- | src/server/database/Database/QueryCallback.h | 36 |
1 files changed, 10 insertions, 26 deletions
diff --git a/src/server/database/Database/QueryCallback.h b/src/server/database/Database/QueryCallback.h index a0aa69ee952..6c4a8a81b4e 100644 --- a/src/server/database/Database/QueryCallback.h +++ b/src/server/database/Database/QueryCallback.h @@ -30,28 +30,6 @@ typedef std::promise<PreparedQueryResult> PreparedQueryResultPromise; class TC_DATABASE_API QueryCallbackNew { - struct String - { - explicit String(std::future<QueryResult>&& result) : Result(std::move(result)) { } - String(String&&) = default; - String& operator=(String&&) = default; - ~String() { } - - std::future<QueryResult> Result; - std::function<void(QueryResult)> Callback; - }; - - struct Prepared - { - explicit Prepared(std::future<PreparedQueryResult>&& result) : Result(std::move(result)) { } - Prepared(Prepared&&) = default; - Prepared& operator=(Prepared&&) = default; - ~Prepared() { } - - std::future<PreparedQueryResult> Result; - std::function<void(PreparedQueryResult)> Callback; - }; - public: explicit QueryCallbackNew(std::future<QueryResult>&& result); explicit QueryCallbackNew(std::future<PreparedQueryResult>&& result); @@ -72,15 +50,21 @@ public: Status InvokeIfReady(); private: - void MoveFrom(QueryCallbackNew&& other); - void DestroyCurrentMember(); + QueryCallbackNew(QueryCallbackNew const& right) = delete; + QueryCallbackNew& operator=(QueryCallbackNew const& right) = delete; + + template<typename T> friend void MoveFrom(T& to, T&& from); + template<typename T> friend void DestroyActiveMember(T& obj); union { - String _string; - Prepared _prepared; + std::future<QueryResult> _string; + std::future<PreparedQueryResult> _prepared; }; bool _isPrepared; + + struct QueryCallbackData; + std::queue<QueryCallbackData, std::list<QueryCallbackData>> _callbacks; }; template <typename Result, typename ParamType, bool chain = false> |