From 4abfe2475af9ee7588d8b3ac3093361e03a441417753acdc203df55b97cf63bd Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sun, 11 Jan 2026 12:15:19 -0500 Subject: [PATCH] Delayed queue for cache is now a vector. --- src/cache.cc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/cache.cc b/src/cache.cc index 602cf34..751167d 100644 --- a/src/cache.cc +++ b/src/cache.cc @@ -82,7 +82,7 @@ static Dlist *ClientQueue; /** A list for delayed clients (it holds weak pointers to cache entries, * which are used to make deferred calls to Cache_process_queue) */ -static Dlist *DelayedQueue; +static std::vector< CacheEntry_t * > DelayedQueue; static uint_t DelayedQueueIdleId = 0; @@ -121,7 +121,6 @@ static int Cache_entry_by_url_cmp(const void *v1, const void *v2) void a_Cache_init(void) { ClientQueue = dList_new(32); - DelayedQueue = dList_new(32); CachedURLs = dList_new(256); /* inject the splash screen in the cache */ @@ -336,7 +335,7 @@ static void Cache_entry_remove(CacheEntry_t *entry, DilloUrl *url) } /* remove from DelayedQueue */ - dList_remove(DelayedQueue, entry); + DelayedQueue.erase( std::find( begin( DelayedQueue ), end( DelayedQueue ), entry ) ); /* remove from dicache */ a_Dicache_invalidate_entry(entry->Url.get()); @@ -1359,11 +1358,11 @@ static void Cache_delayed_process_queue_callback() { CacheEntry_t *entry; - while ((entry = (CacheEntry_t *)dList_nth_data(DelayedQueue, 0))) { + while (not DelayedQueue.empty() and (entry = DelayedQueue.at( 0 ))) { Cache_ref_data(entry); if ((entry = Cache_process_queue(entry))) { Cache_unref_data(entry); - dList_remove(DelayedQueue, entry); + DelayedQueue.erase( std::find( begin( DelayedQueue ), end( DelayedQueue ), entry ) ); } } DelayedQueueIdleId = 0; @@ -1376,8 +1375,8 @@ static void Cache_delayed_process_queue_callback() static void Cache_delayed_process_queue(CacheEntry_t *entry) { /* there's no need to repeat entries in the queue */ - if (!dList_find(DelayedQueue, entry)) - dList_append(DelayedQueue, entry); + if (end( DelayedQueue ) == std::find( begin( DelayedQueue ), end( DelayedQueue ), entry )) + DelayedQueue.push_back( entry ); if (DelayedQueueIdleId == 0) { _MSG(" Setting timeout callback\n"); @@ -1426,7 +1425,7 @@ void a_Cache_stop_client(int Key) /* DelayedQueue */ if ((entry = Cache_entry_search(Client->Url))) - dList_remove(DelayedQueue, entry); + DelayedQueue.erase( std::find( begin( DelayedQueue ), end( DelayedQueue ), entry ) ); /* Main queue */ Cache_client_dequeue(Client);