fix enqueue_once_maybe... maybe?
This commit is contained in:
1 parent
81b41a8bb0
commit
27bbb305fc
1 file changed
+10
-4
@@ -55,15 +55,21 @@ public:
|
||||
unlock();
|
||||
}
|
||||
|
||||
size_t aggregate_hash() { return 0; }
|
||||
template <typename Arg1, typename...Args>
|
||||
size_t aggregate_hash(Arg1& arg1, Args&&... args2) {
|
||||
return
|
||||
std::hash<Arg1>()(arg1) +
|
||||
aggregate_hash(args2...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void enqueue_once_maybe(Subsystem subsystem,Level lv, const char*file, int line,
|
||||
const char *msg_template, Args&&... msg_args) {
|
||||
const size_t filter_size = 1024*8; // 1kb
|
||||
static std::vector<bool> s_bloom(filter_size);
|
||||
std::vector<size_t> hashes {std::hash<std::string>()(msg_template), std::hash<Args>()(msg_args)...};
|
||||
auto arg_hash = std::accumulate(hashes.begin(),hashes.end(),0);
|
||||
size_t hash = (arg_hash+ std::hash<const char*>()(msg_template)) % filter_size;
|
||||
|
||||
auto arg_hash = aggregate_hash(msg_args...);
|
||||
size_t hash = (arg_hash + std::hash<const char*>()(msg_template)) % filter_size;
|
||||
if (s_bloom[hash])
|
||||
return;
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user