summaryrefslogtreecommitdiffstats
path: root/src/libserver/symcache/symcache_internal.hxx
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2022-04-10 11:09:51 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2022-04-10 11:09:51 +0100
commit8214b27e0b9178549116c8c5449271f1fe099a88 (patch)
tree797682ae56013cd2dcdfebe67ffc40596b25fd4e /src/libserver/symcache/symcache_internal.hxx
parenta2f6a34d233b718eac67572a091e456b1c368004 (diff)
downloadrspamd-8214b27e0b9178549116c8c5449271f1fe099a88.tar.gz
rspamd-8214b27e0b9178549116c8c5449271f1fe099a88.zip
[Rework] Re-implement cache sorting
Diffstat (limited to 'src/libserver/symcache/symcache_internal.hxx')
-rw-r--r--src/libserver/symcache/symcache_internal.hxx10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libserver/symcache/symcache_internal.hxx b/src/libserver/symcache/symcache_internal.hxx
index a2b852c19..7dd664e5c 100644
--- a/src/libserver/symcache/symcache_internal.hxx
+++ b/src/libserver/symcache/symcache_internal.hxx
@@ -78,13 +78,16 @@ using cache_item_ptr = std::shared_ptr<cache_item>;
using cache_item_weak_ptr = std::weak_ptr<cache_item>;
struct order_generation {
- std::vector<cache_item_weak_ptr> d;
+ std::vector<cache_item_ptr> d;
unsigned int generation_id;
+
+ explicit order_generation(std::size_t nelts, unsigned id) : generation_id(id) {
+ d.reserve(nelts);
+ }
};
using order_generation_ptr = std::shared_ptr<order_generation>;
-
class symcache;
struct item_condition {
@@ -269,6 +272,9 @@ private:
/* Internal methods */
auto load_items() -> bool;
auto save_items() const -> bool;
+ auto resort() -> void;
+ /* Helper for g_hash_table_foreach */
+ static auto metric_connect_cb(void *k, void *v, void *ud) -> void;
public:
explicit symcache(struct rspamd_config *cfg) : cfg(cfg) {