Joedb 10.0.4
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Client.h
Go to the documentation of this file.
1#ifndef joedb_Client_declared
2#define joedb_Client_declared
3
5
6namespace joedb
7{
8 /// Handle concurrent access to a file with a joedb::Connection
9 ///
10 /// @ingroup concurrency
11 class Client
12 {
13 protected:
14 virtual void read_journal() {}
18
19 int64_t push(int64_t until, Unlock_Action unlock_action)
20 {
22 (
23 journal,
25 until,
26 unlock_action
27 );
28
30 }
31
32 int64_t push(Unlock_Action unlock_action)
33 {
34 return push(journal.get_checkpoint(), unlock_action);
35 }
36
37 public:
38 //////////////////////////////////////////////////////////////////////////
40 //////////////////////////////////////////////////////////////////////////
41 (
44 Content_Check content_check
45 ):
48 connection_checkpoint(connection.handshake(journal, content_check))
49 {
50 }
51
53 {
54 return journal;
55 }
56
57 bool is_shared() const
58 {
59 return journal.is_shared();
60 }
61
62 bool is_pullonly() const
63 {
64 return connection.is_pullonly();
65 }
66
67 int64_t get_journal_checkpoint() const
68 {
69 return get_journal().get_checkpoint();
70 }
71
72 std::string read_blob(Blob blob) const
73 {
74 return get_journal().get_file().read_blob(blob);
75 }
76
78 {
80 }
81
86
87 virtual int64_t push_if_ahead() = 0;
88 virtual int64_t pull
89 (
90 std::chrono::milliseconds wait = std::chrono::milliseconds(0)
91 ) = 0;
92
93 virtual ~Client();
94 };
95}
96
97#endif
Handle concurrent access to a file with a joedb::Connection.
Definition Client.h:12
virtual void read_journal()
Definition Client.h:14
int64_t connection_checkpoint
Definition Client.h:17
int64_t push(Unlock_Action unlock_action)
Definition Client.h:32
int64_t get_journal_checkpoint() const
Definition Client.h:67
int64_t push(int64_t until, Unlock_Action unlock_action)
Definition Client.h:19
bool is_pullonly() const
Definition Client.h:62
Readonly_Journal & journal
Definition Client.h:15
virtual int64_t push_if_ahead()=0
const Readonly_Journal & get_journal() const
Definition Client.h:52
bool is_shared() const
Definition Client.h:57
Connection & connection
Definition Client.h:16
int64_t get_checkpoint_difference() const
Definition Client.h:82
std::string read_blob(Blob blob) const
Definition Client.h:72
int64_t get_connection_checkpoint() const
Definition Client.h:77
virtual ~Client()
virtual int64_t pull(std::chrono::milliseconds wait=std::chrono::milliseconds(0))=0
virtual bool is_pullonly() const
virtual int64_t push(const Readonly_Journal &client_journal, int64_t from, int64_t until, Unlock_Action unlock_action)
Push new data to the connection.
const Buffered_File & get_file() const
int64_t get_checkpoint() const
Content_Check
Definition Connection.h:19
Unlock_Action
Definition Connection.h:41
Definition Blob.h:7