Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
condenser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
condenser
Commits
d26c22aa
Commit
d26c22aa
authored
8 years ago
by
theoreticalbts
Browse files
Options
Downloads
Patches
Plain Diff
Add CHAINBASE_CHECK_LOCKING #define
parent
2bf70658
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/chainbase/chainbase.hpp
+7
-0
7 additions, 0 deletions
include/chainbase/chainbase.hpp
src/chainbase.cpp
+2
-0
2 additions, 0 deletions
src/chainbase.cpp
with
9 additions
and
0 deletions
include/chainbase/chainbase.hpp
+
7
−
0
View file @
d26c22aa
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
#include
<array>
#include
<array>
#include
<atomic>
#include
<atomic>
#include
<fstream>
#include
<fstream>
#include
<iostream>
#include
<stdexcept>
#include
<stdexcept>
#include
<typeindex>
#include
<typeindex>
...
@@ -644,6 +645,7 @@ namespace chainbase {
...
@@ -644,6 +645,7 @@ namespace chainbase {
void
close
();
void
close
();
void
flush
();
void
flush
();
void
wipe
(
const
bfs
::
path
&
dir
);
void
wipe
(
const
bfs
::
path
&
dir
);
#ifdef CHAINBASE_CHECK_LOCKING
void
set_require_locking
(
bool
enable_require_locking
);
void
set_require_locking
(
bool
enable_require_locking
);
void
require_lock_fail
(
const
char
*
lock_type
)
const
;
void
require_lock_fail
(
const
char
*
lock_type
)
const
;
...
@@ -659,6 +661,7 @@ namespace chainbase {
...
@@ -659,6 +661,7 @@ namespace chainbase {
if
(
BOOST_UNLIKELY
(
_enable_require_locking
&
(
_write_lock_count
<=
0
)
)
)
if
(
BOOST_UNLIKELY
(
_enable_require_locking
&
(
_write_lock_count
<=
0
)
)
)
require_lock_fail
(
"write"
);
require_lock_fail
(
"write"
);
}
}
#endif
struct
session
{
struct
session
{
public:
public:
...
@@ -860,9 +863,11 @@ namespace chainbase {
...
@@ -860,9 +863,11 @@ namespace chainbase {
template
<
typename
Lambda
>
template
<
typename
Lambda
>
auto
with_read_lock
(
Lambda
&&
callback
,
uint64_t
wait_micro
=
1000000
)
->
decltype
(
(
*
(
Lambda
*
)
nullptr
)()
)
auto
with_read_lock
(
Lambda
&&
callback
,
uint64_t
wait_micro
=
1000000
)
->
decltype
(
(
*
(
Lambda
*
)
nullptr
)()
)
{
{
#ifdef CHAINBASE_CHECK_LOCKING
read_lock
lock
(
_rw_manager
->
current_lock
(),
bip
::
defer_lock_type
()
);
read_lock
lock
(
_rw_manager
->
current_lock
(),
bip
::
defer_lock_type
()
);
BOOST_ATTRIBUTE_UNUSED
BOOST_ATTRIBUTE_UNUSED
int_incrementer
ii
(
_read_lock_count
);
int_incrementer
ii
(
_read_lock_count
);
#endif
if
(
!
wait_micro
)
if
(
!
wait_micro
)
{
{
...
@@ -884,9 +889,11 @@ namespace chainbase {
...
@@ -884,9 +889,11 @@ namespace chainbase {
if
(
_read_only
)
if
(
_read_only
)
BOOST_THROW_EXCEPTION
(
std
::
logic_error
(
"cannot acquire write lock on read-only process"
)
);
BOOST_THROW_EXCEPTION
(
std
::
logic_error
(
"cannot acquire write lock on read-only process"
)
);
#ifdef CHAINBASE_CHECK_LOCKING
write_lock
lock
(
_rw_manager
->
current_lock
(),
boost
::
defer_lock_t
()
);
write_lock
lock
(
_rw_manager
->
current_lock
(),
boost
::
defer_lock_t
()
);
BOOST_ATTRIBUTE_UNUSED
BOOST_ATTRIBUTE_UNUSED
int_incrementer
ii
(
_write_lock_count
);
int_incrementer
ii
(
_write_lock_count
);
#endif
if
(
!
wait_micro
)
if
(
!
wait_micro
)
{
{
...
...
This diff is collapsed.
Click to expand it.
src/chainbase.cpp
+
2
−
0
View file @
d26c22aa
...
@@ -130,6 +130,7 @@ namespace chainbase {
...
@@ -130,6 +130,7 @@ namespace chainbase {
_index_map
.
clear
();
_index_map
.
clear
();
}
}
#ifdef CHAINBASE_CHECK_LOCKING
void
database
::
set_require_locking
(
bool
enable_require_locking
)
void
database
::
set_require_locking
(
bool
enable_require_locking
)
{
{
_enable_require_locking
=
enable_require_locking
;
_enable_require_locking
=
enable_require_locking
;
...
@@ -141,6 +142,7 @@ namespace chainbase {
...
@@ -141,6 +142,7 @@ namespace chainbase {
std
::
cerr
<<
err_msg
<<
std
::
endl
;
std
::
cerr
<<
err_msg
<<
std
::
endl
;
BOOST_THROW_EXCEPTION
(
std
::
runtime_error
(
err_msg
)
);
BOOST_THROW_EXCEPTION
(
std
::
runtime_error
(
err_msg
)
);
}
}
#endif
void
database
::
undo
()
void
database
::
undo
()
{
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment