File tree 3 files changed +13
-1
lines changed
3 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 4
4
5
5
#include " ccf/indexing/strategy.h"
6
6
#include " ccf/node_subsystem_interface.h"
7
+ #include " ccf/pal/locking.h"
7
8
8
9
#include < map>
9
10
#include < memory>
@@ -19,6 +20,7 @@ namespace ccf::indexing
19
20
class IndexingStrategies : public ccf ::AbstractNodeSubSystem
20
21
{
21
22
protected:
23
+ ccf::pal::Mutex lock;
22
24
std::set<StrategyPtr> strategies;
23
25
24
26
public:
@@ -36,11 +38,13 @@ namespace ccf::indexing
36
38
throw std::logic_error (" Tried to install null strategy" );
37
39
}
38
40
41
+ std::lock_guard<ccf::pal::Mutex> guard (lock);
39
42
return strategies.insert (strategy).second ;
40
43
}
41
44
42
45
void uninstall_strategy (const StrategyPtr& strategy)
43
46
{
47
+ std::lock_guard<ccf::pal::Mutex> guard (lock);
44
48
if (strategy == nullptr || strategies.find (strategy) == strategies.end ())
45
49
{
46
50
throw std::logic_error (" Strategy doesn't exist" );
@@ -49,8 +53,9 @@ namespace ccf::indexing
49
53
strategies.erase (strategy);
50
54
}
51
55
52
- nlohmann::json describe () const
56
+ nlohmann::json describe ()
53
57
{
58
+ std::lock_guard<ccf::pal::Mutex> guard (lock);
54
59
auto j = nlohmann::json::array ();
55
60
56
61
for (const auto & strategy : strategies)
Original file line number Diff line number Diff line change 3
3
#pragma once
4
4
5
5
#include " ccf/kv/read_only_store.h"
6
+ #include " ccf/pal/locking.h"
6
7
#include " ccf/tx_id.h"
7
8
8
9
#include < optional>
@@ -68,6 +69,7 @@ namespace ccf::indexing
68
69
class LazyStrategy : public Base
69
70
{
70
71
protected:
72
+ ccf::pal::Mutex lock;
71
73
ccf::SeqNo max_requested_seqno = 0 ;
72
74
73
75
public:
@@ -78,6 +80,7 @@ namespace ccf::indexing
78
80
const auto base = Base::next_requested ();
79
81
if (base.has_value ())
80
82
{
83
+ std::lock_guard<ccf::pal::Mutex> guard (lock);
81
84
if (*base <= max_requested_seqno)
82
85
{
83
86
return base;
@@ -89,6 +92,7 @@ namespace ccf::indexing
89
92
90
93
void extend_index_to (ccf::TxID to_txid)
91
94
{
95
+ std::lock_guard<ccf::pal::Mutex> guard (lock);
92
96
if (to_txid.seqno > max_requested_seqno)
93
97
{
94
98
max_requested_seqno = to_txid.seqno ;
Original file line number Diff line number Diff line change @@ -68,6 +68,9 @@ namespace ccf::indexing
68
68
update_commit (newly_committed);
69
69
70
70
std::optional<ccf::SeqNo> min_requested = std::nullopt;
71
+
72
+ std::lock_guard<ccf::pal::Mutex> guard (lock);
73
+
71
74
for (auto & strategy : strategies)
72
75
{
73
76
strategy->tick ();
You can’t perform that action at this time.
0 commit comments