Joedb 9.5.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Connection.h
Go to the documentation of this file.
1#ifndef joedb_Connection_declared
2#define joedb_Connection_declared
3
5
6#include <chrono>
7
8namespace joedb
9{
10 /// @ingroup concurrency
12 {
13 public:
15 };
16
17 /// @ingroup concurrency
18 enum class Content_Check
19 {
20 none,
21 quick,
22 full
23 };
24
25 /// @ingroup concurrency
26 enum class Data_Transfer
27 {
28 without_data = 0,
29 with_data = 1
30 };
31
32 /// @ingroup concurrency
33 enum class Lock_Action
34 {
35 no_locking = 0,
36 lock_before = 1
37 };
38
39 /// @ingroup concurrency
40 enum class Unlock_Action
41 {
42 keep_locked = 0,
43 unlock_after = 1
44 };
45
46 /// @ingroup concurrency
48 {
49 protected:
50 /// Called by @ref handshake when the file and the connection do not match
51 static void content_mismatch();
52
53 public:
54 /// Called during Client construction
55 ///
56 /// @param client_journal may be used to check matching content
57 /// @param content_check indicates how matching content is tested
58 ///
59 /// @retval connection checkpoint
60 virtual int64_t handshake
61 (
62 const Readonly_Journal &client_journal,
63 Content_Check content_check
64 );
65
66 /// Pull from the connection
67 ///
68 /// @param lock_action whether the connection should be locked before pulling
69 /// @param data_transfer whether data should be transferred
70 /// @param client_journal journal to pull into
71 /// @param wait duration during which the connection may wait
72 /// for new data if the pull would otherwise be empty
73 ///
74 /// @retval server checkpoint
75 virtual int64_t pull
76 (
77 Lock_Action lock_action,
78 Data_Transfer data_transfer,
79 Writable_Journal &client_journal,
80 std::chrono::milliseconds wait = std::chrono::milliseconds(0)
81 );
82
83 /// Push new data to the connection
84 ///
85 /// @retval server checkpoint
86 virtual int64_t push
87 (
88 const Readonly_Journal &client_journal,
89 int64_t from,
90 int64_t until,
91 Unlock_Action unlock_action
92 );
93
94 /// Unlock the connection
95 virtual void unlock();
96
97 virtual bool is_pullonly() const;
98
99 virtual ~Connection();
100 };
101}
102
103#endif
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.
virtual void unlock()
Unlock the connection.
virtual ~Connection()
virtual int64_t pull(Lock_Action lock_action, Data_Transfer data_transfer, Writable_Journal &client_journal, std::chrono::milliseconds wait=std::chrono::milliseconds(0))
Pull from the connection.
static void content_mismatch()
Called by handshake when the file and the connection do not match.
virtual int64_t handshake(const Readonly_Journal &client_journal, Content_Check content_check)
Called during Client construction.
Data_Transfer
Definition Connection.h:27
Lock_Action
Definition Connection.h:34
Content_Check
Definition Connection.h:19
Unlock_Action
Definition Connection.h:41
Definition Blob.h:7