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
2bf70658
Commit
2bf70658
authored
8 years ago
by
theoreticalbts
Browse files
Options
Downloads
Patches
Plain Diff
Fix compile warning, report lock timeouts
parent
a20d75ae
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/chainbase/chainbase.hpp
+8
-2
8 additions, 2 deletions
include/chainbase/chainbase.hpp
with
8 additions
and
2 deletions
include/chainbase/chainbase.hpp
+
8
−
2
View file @
2bf70658
...
...
@@ -618,6 +618,11 @@ namespace chainbase {
return
_locks
[
_current_lock
%
CHAINBASE_NUM_RW_LOCKS
];
}
uint32_t
current_lock_num
()
{
return
_current_lock
;
}
private
:
std
::
array
<
read_write_mutex
,
CHAINBASE_NUM_RW_LOCKS
>
_locks
;
std
::
atomic
<
uint32_t
>
_current_lock
;
...
...
@@ -856,8 +861,8 @@ namespace chainbase {
auto
with_read_lock
(
Lambda
&&
callback
,
uint64_t
wait_micro
=
1000000
)
->
decltype
(
(
*
(
Lambda
*
)
nullptr
)()
)
{
read_lock
lock
(
_rw_manager
->
current_lock
(),
bip
::
defer_lock_type
()
);
BOOST_ATTRIBUTE_UNUSED
int_incrementer
ii
(
_read_lock_count
);
ii
.
get
();
// prevent unused variable warning
if
(
!
wait_micro
)
{
...
...
@@ -880,8 +885,8 @@ namespace chainbase {
BOOST_THROW_EXCEPTION
(
std
::
logic_error
(
"cannot acquire write lock on read-only process"
)
);
write_lock
lock
(
_rw_manager
->
current_lock
(),
boost
::
defer_lock_t
()
);
BOOST_ATTRIBUTE_UNUSED
int_incrementer
ii
(
_write_lock_count
);
ii
.
get
();
// prevent unused variable warning
if
(
!
wait_micro
)
{
...
...
@@ -892,6 +897,7 @@ namespace chainbase {
while
(
!
lock
.
timed_lock
(
boost
::
posix_time
::
microsec_clock
::
local_time
()
+
boost
::
posix_time
::
microseconds
(
wait_micro
)
)
)
{
_rw_manager
->
next_lock
();
std
::
cerr
<<
"Lock timeout, moving to lock "
<<
_rw_manager
->
current_lock_num
()
<<
std
::
endl
;
lock
=
write_lock
(
_rw_manager
->
current_lock
(),
boost
::
defer_lock_t
()
);
}
}
...
...
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