Joedb 10.2.1
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
6
7#include <chrono>
8
9namespace joedb
10{
11 /// @ingroup concurrency
13 {
14 public:
16 };
17
18 /// @ingroup concurrency
19 enum class Content_Check
20 {
21 none,
22 fast,
23 full
24 };
25
26 /// @ingroup concurrency
27 enum class Data_Transfer
28 {
29 without_data = 0,
30 with_data = 1
31 };
32
33 /// @ingroup concurrency
34 enum class Lock_Action
35 {
36 no_locking = 0,
37 lock_before = 1
38 };
39
40 /// @ingroup concurrency
41 enum class Unlock_Action
42 {
43 keep_locked = 0,
44 unlock_after = 1
45 };
46
47 /// @ingroup concurrency
49 {
50 protected:
51 /// Called by @ref handshake when the file and the connection do not match
52 static void content_mismatch();
53
54 Connection() = default; // Force using Connection::dummy
55
56 public:
57 /// Called during Client construction
58 ///
59 /// @param client_journal may be used to check matching content
60 /// @param content_check indicates how matching content is tested
61 ///
62 /// @return connection checkpoint
63 virtual int64_t handshake
64 (
65 const Readonly_Journal &client_journal,
66 Content_Check content_check
67 );
68
69 /// Pull from the connection
70 ///
71 /// @param lock_action whether the connection should be locked before pulling
72 /// @param data_transfer whether data should be transferred
73 /// @param client_journal journal to pull into
74 /// @param wait duration during which the connection may wait
75 /// for new data if the pull would otherwise be empty
76 ///
77 /// @return connection checkpoint
78 virtual int64_t pull
79 (
80 Lock_Action lock_action,
81 Data_Transfer data_transfer,
82 Writable_Journal &client_journal,
83 std::chrono::milliseconds wait = std::chrono::milliseconds(0)
84 );
85
86 /// Push new data to the connection
87 ///
88 /// @return connection checkpoint
89 virtual int64_t push
90 (
91 const Readonly_Journal &client_journal,
92 int64_t from,
93 int64_t until,
94 Unlock_Action unlock_action
95 );
96
97 /// Unlock the connection
98 virtual void unlock();
99
100 virtual bool is_pullonly() const;
101
102 virtual ~Connection();
103
104 /// Since this class has no internal state, this global variable
105 /// can be used instead of creating an instance.
106 /// The default constructor is protected to force using it.
108 };
109}
110
111#endif
virtual bool is_pullonly() const
static Connection dummy
Since this class has no internal state, this global variable can be used instead of creating an insta...
Definition Connection.h:107
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.
Connection()=default
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.
joedb::Robust_Connection does not try to reconnect when thrown
Data_Transfer
Definition Connection.h:28
Lock_Action
Definition Connection.h:35
Content_Check
Definition Connection.h:20
Unlock_Action
Definition Connection.h:42