Commit bd7e7e31 authored by cdjgit's avatar cdjgit

fix for ci comments

parent c9a9ffa3
...@@ -121,14 +121,20 @@ bool KetamaReplicaPolicy::Build(ServerId server, ...@@ -121,14 +121,20 @@ bool KetamaReplicaPolicy::Build(ServerId server,
namespace { namespace {
const std::array<const ReplicaPolicy*, CONS_HASH_LB_LAST> g_replica_policy = { pthread_once_t s_replica_policy_once = PTHREAD_ONCE_INIT;
new DefaultReplicaPolicy(MurmurHash32), const std::array<const ReplicaPolicy*, CONS_HASH_LB_LAST>* g_replica_policy = nullptr;
new DefaultReplicaPolicy(MD5Hash32),
new KetamaReplicaPolicy void init_replica_policy() {
}; g_replica_policy = new std::array<const ReplicaPolicy*, CONS_HASH_LB_LAST>({
new DefaultReplicaPolicy(MurmurHash32),
new DefaultReplicaPolicy(MD5Hash32),
new KetamaReplicaPolicy
});
}
inline const ReplicaPolicy* GetReplicaPolicy(ConsistentHashingLoadBalancerType type) { inline const ReplicaPolicy* GetReplicaPolicy(ConsistentHashingLoadBalancerType type) {
return g_replica_policy.at(type); pthread_once(&s_replica_policy_once, init_replica_policy);
return g_replica_policy->at(type);
} }
} // namespace } // namespace
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment