Joedb 10.0.1
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:
31
32 int64_t pull
33 (
34 std::chrono::milliseconds wait = std::chrono::milliseconds(0)
35 ) override
36 {
37 const int64_t result = Readonly_Journal::pull();
38 if (result)
40 return result;
41 }
42
51
53 {
54 try {connection.unlock();} catch (...) {}
55 }
56 };
57}
58
59#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(Unlock_Action unlock_action)
Definition Client.h:19
Connection & connection
Definition Client.h:16
int64_t get_connection_checkpoint() const
Definition Client.h:72
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 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