Joedb 10.3.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Server_Client.h
Go to the documentation of this file.
1#ifndef joedb_Server_Client_declared
2#define joedb_Server_Client_declared
3
5#include "joedb/Thread_Safe.h"
9
10#include <condition_variable>
11#include <thread>
12#include <chrono>
13
14namespace joedb
15{
16 /// @ingroup concurrency
17 class Server_Client: public Logger
18 {
19 friend class Server_File;
20
21 private:
22 std::chrono::milliseconds keep_alive_interval;
23 std::condition_variable condition;
24 void ping(Lock<Channel&> &lock);
25 bool keep_alive_thread_must_stop;
26 std::thread keep_alive_thread;
27 void keep_alive();
28 void connect();
29 void disconnect() noexcept;
30
31 protected:
35
36 mutable Buffer<13> buffer;
37
38 int64_t session_id;
41
42 void download
43 (
44 Async_Writer &writer,
45 Lock<Channel&> &lock,
46 int64_t size
47 ) const;
48
49 void log(const std::string &message) noexcept override;
50
51 public:
52 ///
53 /// @param keep_alive_interval: a background thread will send a ping
54 /// to the server at this interval. Setting this parameter to zero disables
55 /// the keep-alive background thread.
56 ///
58 (
61 std::chrono::milliseconds keep_alive_interval = std::chrono::seconds(0)
62 );
63
64 int64_t get_session_id() const {return session_id;}
66 void ping();
67
69 };
70}
71
72#endif
static Logger dummy_logger
Definition Logger.h:14
void log(const std::string &message) noexcept override
Thread_Safe< Channel & > channel
Thread_Safe< Channel & > & get_channel()
void download(Async_Writer &writer, Lock< Channel & > &lock, int64_t size) const
int64_t get_session_id() const
Directly read file served from joedb_server.
Definition Server_File.h:22