mirror of
https://github.com/KingDuckZ/incredis
synced 2025-08-07 12:59:46 +00:00
Optimization - don't use futures, use simple pointers.
The local count atomic is used to tell if there are any unanswered ex-futures yet.
This commit is contained in:
parent
930fde41c8
commit
657ecd63e2
5 changed files with 55 additions and 22 deletions
|
@ -23,10 +23,6 @@
|
|||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
namespace std {
|
||||
template <class R> class future;
|
||||
} //namespace std
|
||||
|
||||
namespace redis {
|
||||
class Command;
|
||||
class AsyncConnection;
|
||||
|
@ -40,6 +36,7 @@ namespace redis {
|
|||
~Batch ( void ) noexcept;
|
||||
|
||||
const std::vector<Reply>& replies ( void );
|
||||
std::vector<Reply>& replies_nonconst ( void );
|
||||
bool replies_requested ( void ) const;
|
||||
void throw_if_failed ( void );
|
||||
|
||||
|
@ -57,7 +54,7 @@ namespace redis {
|
|||
explicit Batch ( AsyncConnection* parConn, ThreadContext& parThreadContext );
|
||||
void run_pvt ( int parArgc, const char** parArgv, std::size_t* parLengths );
|
||||
|
||||
std::vector<std::future<Reply>> m_futures;
|
||||
std::vector<std::unique_ptr<Reply>> m_futures;
|
||||
std::vector<Reply> m_replies;
|
||||
std::unique_ptr<LocalData> m_local_data;
|
||||
AsyncConnection* m_async_conn;
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace redis {
|
|||
auto batch = make_batch();
|
||||
batch.run(parCommand, std::forward<Args>(parArgs)...);
|
||||
batch.throw_if_failed();
|
||||
return batch.replies().front();
|
||||
return std::move(batch.replies_nonconst().front());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -77,8 +77,14 @@ namespace redis {
|
|||
Reply ( ErrorString&& parVal ) : base_class(std::move(parVal)) {}
|
||||
Reply ( StatusString&& parVal ) : base_class(std::move(parVal)) {}
|
||||
Reply ( std::nullptr_t parVal ) : base_class(parVal) {}
|
||||
|
||||
Reply ( Reply&& ) = default;
|
||||
Reply ( const Reply& ) = default;
|
||||
~Reply ( void ) noexcept = default;
|
||||
|
||||
Reply& operator= ( Reply&& ) = default;
|
||||
Reply& operator= ( const Reply& ) = default;
|
||||
|
||||
bool is_integer ( void ) const;
|
||||
bool is_string ( void ) const;
|
||||
bool is_array ( void ) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue