diff options
author | Adam Ierymenko <adam.ierymenko@zerotier.com> | 2018-04-25 06:39:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-25 06:39:02 -0700 |
commit | 42ec780a6f6eedef4d8b1d8218bd72fc6ed75cc0 (patch) | |
tree | 7bf86c4d92d6a0f77eced79bfc33313c62c7b6dd /ext/librethinkdbxx/src/connection.h | |
parent | 18c9dc8a0649c866eff9f299f20fa5b19c502e52 (diff) | |
parent | 4608880fb06700822d01e9e5d6729fcdeb82b64b (diff) | |
download | infinitytier-42ec780a6f6eedef4d8b1d8218bd72fc6ed75cc0.tar.gz infinitytier-42ec780a6f6eedef4d8b1d8218bd72fc6ed75cc0.zip |
Merge branch 'dev' into netbsd-support
Diffstat (limited to 'ext/librethinkdbxx/src/connection.h')
-rw-r--r-- | ext/librethinkdbxx/src/connection.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/ext/librethinkdbxx/src/connection.h b/ext/librethinkdbxx/src/connection.h new file mode 100644 index 00000000..d3882857 --- /dev/null +++ b/ext/librethinkdbxx/src/connection.h @@ -0,0 +1,59 @@ +#pragma once + +#include <string> +#include <queue> +#include <mutex> +#include <memory> +#include <condition_variable> + +#include "protocol_defs.h" +#include "datum.h" +#include "error.h" + +#define FOREVER (-1) +#define SECOND 1 +#define MICROSECOND 0.000001 + +namespace RethinkDB { + +class Term; +using OptArgs = std::map<std::string, Term>; + +// A connection to a RethinkDB server +// It contains: +// * A socket +// * Read and write locks +// * A cache of responses that have not been read by the corresponding Cursor +class ConnectionPrivate; +class Connection { +public: + Connection() = delete; + Connection(const Connection&) noexcept = delete; + Connection(Connection&&) noexcept = delete; + Connection& operator=(Connection&&) noexcept = delete; + Connection& operator=(const Connection&) noexcept = delete; + ~Connection(); + + void close(); + +private: + explicit Connection(ConnectionPrivate *dd); + std::unique_ptr<ConnectionPrivate> d; + + Cursor start_query(Term *term, OptArgs&& args); + void stop_query(uint64_t); + void continue_query(uint64_t); + + friend class Cursor; + friend class CursorPrivate; + friend class Token; + friend class Term; + friend std::unique_ptr<Connection> + connect(std::string host, int port, std::string auth_key); + +}; + +// $doc(connect) +std::unique_ptr<Connection> connect(std::string host = "localhost", int port = 28015, std::string auth_key = ""); + +} |