RemoteTagCache: use IntrusiveHashSet instead of boost::intrusive::unordered_set
This commit is contained in:
parent
c943e27d51
commit
a43062c575
@ -30,8 +30,7 @@ static constexpr Domain remote_tag_cache_domain("remote_tag_cache");
|
|||||||
RemoteTagCache::RemoteTagCache(EventLoop &event_loop,
|
RemoteTagCache::RemoteTagCache(EventLoop &event_loop,
|
||||||
RemoteTagCacheHandler &_handler) noexcept
|
RemoteTagCacheHandler &_handler) noexcept
|
||||||
:handler(_handler),
|
:handler(_handler),
|
||||||
defer_invoke_handler(event_loop, BIND_THIS_METHOD(InvokeHandlers)),
|
defer_invoke_handler(event_loop, BIND_THIS_METHOD(InvokeHandlers))
|
||||||
map(typename KeyMap::bucket_traits(&buckets.front(), buckets.size()))
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,11 +44,10 @@ RemoteTagCache::Lookup(const std::string &uri) noexcept
|
|||||||
{
|
{
|
||||||
std::unique_lock<Mutex> lock(mutex);
|
std::unique_lock<Mutex> lock(mutex);
|
||||||
|
|
||||||
KeyMap::insert_commit_data hint;
|
auto [tag, value] = map.insert_check(uri);
|
||||||
auto [tag, value] = map.insert_check(uri, Item::Hash(), Item::Equal(), hint);
|
|
||||||
if (value) {
|
if (value) {
|
||||||
auto item = new Item(*this, uri);
|
auto item = new Item(*this, uri);
|
||||||
map.insert_commit(*item, hint);
|
map.insert(tag, *item);
|
||||||
waiting_list.push_back(*item);
|
waiting_list.push_back(*item);
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
||||||
|
@ -25,8 +25,7 @@
|
|||||||
#include "event/InjectEvent.hxx"
|
#include "event/InjectEvent.hxx"
|
||||||
#include "thread/Mutex.hxx"
|
#include "thread/Mutex.hxx"
|
||||||
#include "util/IntrusiveList.hxx"
|
#include "util/IntrusiveList.hxx"
|
||||||
|
#include "util/IntrusiveHashSet.hxx"
|
||||||
#include <boost/intrusive/unordered_set.hpp>
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -45,7 +44,7 @@ class RemoteTagCache final {
|
|||||||
Mutex mutex;
|
Mutex mutex;
|
||||||
|
|
||||||
struct Item final
|
struct Item final
|
||||||
: public boost::intrusive::unordered_set_base_hook<boost::intrusive::link_mode<boost::intrusive::normal_link>>,
|
: public IntrusiveHashSetHook<>,
|
||||||
public IntrusiveListHook<>,
|
public IntrusiveListHook<>,
|
||||||
RemoteTagHandler
|
RemoteTagHandler
|
||||||
{
|
{
|
||||||
@ -113,12 +112,9 @@ class RemoteTagCache final {
|
|||||||
*/
|
*/
|
||||||
ItemList invoke_list;
|
ItemList invoke_list;
|
||||||
|
|
||||||
typedef boost::intrusive::unordered_set<Item,
|
using KeyMap = IntrusiveHashSet<Item, 127, Item::Hash, Item::Equal,
|
||||||
boost::intrusive::hash<Item::Hash>,
|
IntrusiveHashSetBaseHookTraits<Item>,
|
||||||
boost::intrusive::equal<Item::Equal>,
|
true>;
|
||||||
boost::intrusive::constant_time_size<true>> KeyMap;
|
|
||||||
|
|
||||||
std::array<typename KeyMap::bucket_type, 127> buckets;
|
|
||||||
|
|
||||||
KeyMap map;
|
KeyMap map;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user