Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
chainbase.cpp
Go to the documentation of this file.
2#include <boost/array.hpp>
3
4#include <iostream>
5
6#ifndef _WIN32
7#include <sys/mman.h>
8#endif
9
10namespace chainbase {
11
12 database::database(const bfs::path& dir, open_flags flags, uint64_t shared_file_size, bool allow_dirty,
14 _db_file(dir, flags & database::read_write, shared_file_size, allow_dirty, db_map_mode),
15 _read_only(flags == database::read_only)
16 {
17 }
18
20 {
21 _index_list.clear();
22 _index_map.clear();
23 }
24
25 void database::set_require_locking( bool enable_require_locking )
26 {
27#ifdef CHAINBASE_CHECK_LOCKING
28 _enable_require_locking = enable_require_locking;
29#endif
30 }
31
32#ifdef CHAINBASE_CHECK_LOCKING
33 void database::require_lock_fail( const char* method, const char* lock_type, const char* tname )const
34 {
35 std::string err_msg = "database::" + std::string( method ) + " require_" + std::string( lock_type ) + "_lock() failed on type " + std::string( tname );
36 std::cerr << err_msg << std::endl;
37 BOOST_THROW_EXCEPTION( std::runtime_error( err_msg ) );
38 }
39#endif
40
42 {
43 for( auto& item : _index_list )
44 {
45 item->undo();
46 }
47 }
48
50 {
51 for( auto& item : _index_list )
52 {
53 item->squash();
54 }
55 }
56
57 void database::commit( int64_t revision )
58 {
59 for( auto& item : _index_list )
60 {
61 item->commit( revision );
62 }
63 }
64
66 {
67 for( auto& item : _index_list )
68 {
69 item->undo_all();
70 }
71 }
72
74 {
75 if( enabled ) {
76 vector< std::unique_ptr<abstract_session> > _sub_sessions;
77 _sub_sessions.reserve( _index_list.size() );
78 for( auto& item : _index_list ) {
79 _sub_sessions.push_back( item->start_undo_session( enabled ) );
80 }
81 return session( std::move( _sub_sessions ) );
82 } else {
83 return session();
84 }
85 }
86
87} // namespace chainbase
int64_t revision() const
database(const bfs::path &dir, open_flags write=read_only, uint64_t shared_file_size=0, bool allow_dirty=false, pinnable_mapped_file::map_mode=pinnable_mapped_file::map_mode::mapped)
Definition chainbase.cpp:12
session start_undo_session(bool enabled)
Definition chainbase.cpp:73
void commit(int64_t revision)
Definition chainbase.cpp:57
void set_require_locking(bool enable_require_locking)
Definition chainbase.cpp:25
CK_SESSION_HANDLE session
signed __int64 int64_t
Definition stdint.h:135
unsigned __int64 uint64_t
Definition stdint.h:136
pInfo flags