X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/fb2d2e17e3ffc4bddf944dc67a6d86fe9453bb5a..836d44ecb7a2c37427f6baf8b25e872e9e943d5b:/lunaix-os/includes/lunaix/ds/lru.h diff --git a/lunaix-os/includes/lunaix/ds/lru.h b/lunaix-os/includes/lunaix/ds/lru.h index 63660c2..622d6e4 100644 --- a/lunaix-os/includes/lunaix/ds/lru.h +++ b/lunaix-os/includes/lunaix/ds/lru.h @@ -2,6 +2,7 @@ #define __LUNAIX_LRU_H #include +#include #include struct lru_node @@ -15,12 +16,29 @@ struct lru_zone { struct llist_header lead_node; struct llist_header zones; - uint32_t objects; + char name[32]; evict_cb try_evict; + spinlock_t lock; + + unsigned int objects; + unsigned int hotness; + struct { + unsigned int n_single; + unsigned int n_half; + unsigned int n_full; + } evict_stats; + + union { + struct { + bool delayed_free:1; + unsigned char attempts; + }; + unsigned int flags; + }; }; struct lru_zone* -lru_new_zone(evict_cb try_evict_cb); +lru_new_zone(const char* name, evict_cb try_evict_cb); void lru_use_one(struct lru_zone* zone, struct lru_node* node); @@ -34,4 +52,10 @@ lru_remove(struct lru_zone* zone, struct lru_node* node); void lru_evict_half(struct lru_zone* zone); +void +lru_evict_all(struct lru_zone* zone); + +void +lru_free_zone(struct lru_zone* zone); + #endif /* __LUNAIX_LRU_H */