X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/af8e873ae38b72a56a89485c62bb5ccd22a9f8a7..8fce4520de1f257819b16f9253fa28dcdae743f4:/lunaix-os/includes/lunaix/ds/lru.h?ds=sidebyside diff --git a/lunaix-os/includes/lunaix/ds/lru.h b/lunaix-os/includes/lunaix/ds/lru.h index 5ae607d..76c9597 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; + u32_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 */