Joedb 10.2.3
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"
8
9#include <condition_variable>
10#include <thread>
11#include <iosfwd>
12#include <chrono>
13
14namespace joedb
15{
16 /// @ingroup concurrency
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:
33 std::ostream *log;
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 public:
50 ///
51 /// @param keep_alive_interval: a background thread will send a ping
52 /// to the server at this interval. Setting this parameter to zero disables
53 /// the keep-alive background thread.
54 ///
56 (
58 std::ostream *log = nullptr,
59 std::chrono::milliseconds keep_alive_interval = std::chrono::seconds(0)
60 );
61
62 int64_t get_session_id() const {return session_id;}
64 void ping();
65
67 };
68}
69
70#endif
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
std::ostream * log
Directly read file served from joedb_server.
Definition Server_File.h:22