Joedb 10.0.3
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Readonly_Client.h
Go to the documentation of this file.
1#ifndef joedb_Readonly_Client_declared
2#define joedb_Readonly_Client_declared
3
5
6namespace joedb
7{
8 /// Specialized client for read-only files
9 ///
10 /// This Client has no support for transactions: the connection is locked
11 /// in the constructor and unlocked in the destructor. Only allowed
12 /// operations are pulling from the journal, and pushing to the connection.
13 ///
14 /// @ingroup concurrency
15 class Readonly_Client: protected Readonly_Journal, public Client
16 {
17 public:
19 (
22 Content_Check content_check = Content_Check::fast,
23 Recovery recovery = Recovery::none
24 ):
26 Client(*this, connection, content_check)
27 {
29 }
30
31 int64_t pull
32 (
33 std::chrono::milliseconds wait = std::chrono::milliseconds(0)
34 ) override
35 {
36 const int64_t result = Readonly_Journal::pull();
37 if (result)
39 return result;
40 }
41
42 int64_t push_if_ahead(int64_t until)
43 {
44 pull();
47 else
49 }
50
51 int64_t push_if_ahead() override
52 {
54 }
55
57 {
58 try {connection.unlock();} catch (...) {}
59 }
60 };
61}
62
63#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 push(int64_t until, Unlock_Action unlock_action)
Definition Client.h:19
Connection & connection
Definition Client.h:16
int64_t get_connection_checkpoint() const
Definition Client.h:77
virtual void unlock()
Unlock the connection.
Specialized client for read-only files.
Readonly_Client(Buffered_File &file, Connection &connection, Content_Check content_check=Content_Check::fast, Recovery recovery=Recovery::none)
int64_t push_if_ahead(int64_t until)
int64_t pull(std::chrono::milliseconds wait=std::chrono::milliseconds(0)) override
int64_t push_if_ahead() override
int64_t get_checkpoint() const
Content_Check
Definition Connection.h:19
@ none
default: fail if file size > checkpoint
Definition Blob.h:7