]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/store/LocalSearch.cc
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 /* DEBUG: section 47 Store Search */
14 #include "store/LocalSearch.h"
15 #include "StoreSearch.h"
19 /// iterates local store_table
20 class LocalSearch
: public StoreSearch
22 CBDATA_CLASS(LocalSearch
);
28 virtual void next(void (callback
)(void *cbdata
), void *cbdata
) override
;
29 virtual bool next() override
;
30 virtual bool error() const override
;
31 virtual bool isDone() const override
;
32 virtual StoreEntry
*currentItem() override
;
36 void (*callback
)(void *cbdata
);
40 std::vector
<StoreEntry
*> entries
;
45 CBDATA_NAMESPACED_CLASS_INIT(Store
, LocalSearch
);
48 Store::NewLocalSearch()
50 return new LocalSearch
;
53 Store::LocalSearch::LocalSearch() :
61 Store::LocalSearch::next(void (aCallback
)(void *), void *aCallbackData
)
64 aCallback (aCallbackData
);
68 Store::LocalSearch::next()
73 while (!isDone() && !entries
.size())
76 return currentItem() != NULL
;
80 Store::LocalSearch::error() const
86 Store::LocalSearch::isDone() const
88 return bucket
>= store_hash_buckets
|| _done
;
92 Store::LocalSearch::currentItem()
97 return entries
.back();
101 Store::LocalSearch::copyBucket()
103 /* probably need to lock the store entries...
104 * we copy them all to prevent races on the links. */
105 debugs(47, 3, "Store::LocalSearch::copyBucket #" << bucket
);
106 assert (!entries
.size());
107 hash_link
*link_ptr
= NULL
;
108 hash_link
*link_next
= NULL
;
109 link_next
= hash_get_bucket(store_table
, bucket
);
111 while (NULL
!= (link_ptr
= link_next
)) {
112 link_next
= link_ptr
->next
;
113 StoreEntry
*e
= (StoreEntry
*) link_ptr
;
115 entries
.push_back(e
);
119 debugs(47,3, "got entries: " << entries
.size());