mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 18:35:46 +02:00
fix(server): Fix lambda capture in RunInParallel functions (#507)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
This commit is contained in:
parent
235ff67e44
commit
da03cd8344
1 changed files with 7 additions and 15 deletions
|
@ -23,7 +23,6 @@ extern "C" {
|
|||
#include "util/proactor_pool.h"
|
||||
#include "util/sliding_counter.h"
|
||||
|
||||
|
||||
namespace dfly {
|
||||
|
||||
namespace journal {
|
||||
|
@ -98,7 +97,6 @@ class EngineShard {
|
|||
return &shard_lock_;
|
||||
}
|
||||
|
||||
|
||||
// TODO: Awkward interface. I should solve it somehow.
|
||||
void ShutdownMulti(Transaction* multi);
|
||||
|
||||
|
@ -113,7 +111,9 @@ class EngineShard {
|
|||
// Returns used memory for this shard.
|
||||
size_t UsedMemory() const;
|
||||
|
||||
TieredStorage* tiered_storage() { return tiered_storage_.get(); }
|
||||
TieredStorage* tiered_storage() {
|
||||
return tiered_storage_.get();
|
||||
}
|
||||
|
||||
// Adds blocked transaction to the watch-list.
|
||||
void AddBlocked(Transaction* trans);
|
||||
|
@ -125,13 +125,8 @@ class EngineShard {
|
|||
// for everyone to use for string transformations during atomic cpu sequences.
|
||||
sds tmp_str1;
|
||||
|
||||
|
||||
// Moving average counters.
|
||||
enum MovingCnt {
|
||||
TTL_TRAVERSE,
|
||||
TTL_DELETE,
|
||||
COUNTER_TOTAL
|
||||
};
|
||||
enum MovingCnt { TTL_TRAVERSE, TTL_DELETE, COUNTER_TOTAL };
|
||||
|
||||
// Returns moving sum over the last 6 seconds.
|
||||
uint32_t GetMovingSum6(MovingCnt type) const {
|
||||
|
@ -158,7 +153,6 @@ class EngineShard {
|
|||
|
||||
void CacheStats();
|
||||
|
||||
|
||||
::util::fibers_ext::FiberQueue queue_;
|
||||
::boost::fibers::fiber fiber_q_;
|
||||
|
||||
|
@ -257,8 +251,8 @@ void EngineShardSet::RunBriefInParallel(U&& func, P&& pred) const {
|
|||
|
||||
bc.Add(1);
|
||||
util::ProactorBase* dest = pp_->at(i);
|
||||
dest->DispatchBrief([f = std::forward<U>(func), bc]() mutable {
|
||||
f(EngineShard::tlocal());
|
||||
dest->DispatchBrief([&func, bc]() mutable {
|
||||
func(EngineShard::tlocal());
|
||||
bc.Dec();
|
||||
});
|
||||
}
|
||||
|
@ -272,7 +266,7 @@ template <typename U> void EngineShardSet::RunBlockingInParallel(U&& func) {
|
|||
util::ProactorBase* dest = pp_->at(i);
|
||||
|
||||
// the "Dispatch" call spawns a fiber underneath.
|
||||
dest->Dispatch([func, bc]() mutable {
|
||||
dest->Dispatch([&func, bc]() mutable {
|
||||
func(EngineShard::tlocal());
|
||||
bc.Dec();
|
||||
});
|
||||
|
@ -285,7 +279,6 @@ inline ShardId Shard(std::string_view v, ShardId shard_num) {
|
|||
return hash % shard_num;
|
||||
}
|
||||
|
||||
|
||||
// absl::GetCurrentTimeNanos is twice faster than clock_gettime(CLOCK_REALTIME) on my laptop
|
||||
// and 4 times faster than on a VM. it takes 5-10ns to do a call.
|
||||
|
||||
|
@ -295,7 +288,6 @@ inline uint64_t GetCurrentTimeMs() {
|
|||
return TEST_current_time_ms ? TEST_current_time_ms : absl::GetCurrentTimeNanos() / 1000000;
|
||||
}
|
||||
|
||||
|
||||
extern EngineShardSet* shard_set;
|
||||
|
||||
} // namespace dfly
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue