Re: [PATCH] hash table: add a bucket iterator function
From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2018-08-03 15:24:22
From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2018-08-03 15:24:22
On Wed, 1 Aug 2018 08:57:39 -0400 Michel Machado [off-list ref] wrote:
On 07/31/2018 09:40 PM, Wang, Yipeng1 wrote:quoted
How about an API that is more universal? For example, an API such as "rte_iterate_conflict_entries". After an insertion failure, this function will iterate all entries that may conflict with the newly inserted key and you could decide which entry to evict?Fine. We'll rewrite the patch to do so. Thank you for the feedback. [ ]'s Michel Machado
Often for time based cleanup it is better to have a second linked list that is ordered by time value. Then the cleanup code can start at the oldest stop when it reaches the last item that could expire. That does mean having some form of lock and doing delete/insert on every usage. i.e spinlock(&timer_lock); TAILQ_REMOVE(&timer_list, entry, timer_list); entry->expiration = new time; TAILQ_INSERT_TAIL(&timer_list, entry, timer_list); spinunlock(&timer_unlock);