X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/bc34fd00d2e81fbc890bb2060ed6693454a230bf..ea77b9c3fc7fb9bf9d7f9604fc187c8049212a2a:/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 5ae607d..63660c2 100644 --- a/lunaix-os/includes/lunaix/ds/lru.h +++ b/lunaix-os/includes/lunaix/ds/lru.h @@ -2,28 +2,36 @@ #define __LUNAIX_LRU_H #include +#include -struct lru_zone +struct lru_node { - struct llist_header lead_node; - struct llist_header zones; + struct llist_header lru_nodes; }; -struct lru_node +typedef int (*evict_cb)(struct lru_node* lru_obj); + +struct lru_zone { - struct llist_header lru_nodes; + struct llist_header lead_node; + struct llist_header zones; + uint32_t objects; + evict_cb try_evict; }; struct lru_zone* -lru_new_zone(); +lru_new_zone(evict_cb try_evict_cb); void lru_use_one(struct lru_zone* zone, struct lru_node* node); -struct lru_node* +void lru_evict_one(struct lru_zone* zone); void -lru_remove(struct lru_node* node); +lru_remove(struct lru_zone* zone, struct lru_node* node); + +void +lru_evict_half(struct lru_zone* zone); #endif /* __LUNAIX_LRU_H */