client/List: use IntrusiveList instead of boost::intrusive::list

This commit is contained in:
Max Kellermann 2022-09-20 22:10:19 +02:00
parent 988f5d1b5d
commit 1da8faa285
3 changed files with 16 additions and 17 deletions

View File

@ -29,14 +29,13 @@
#include "player/Control.hxx"
#include "player/Listener.hxx"
#include "protocol/RangeArg.hxx"
#include "util/IntrusiveList.hxx"
#include "ReplayGainMode.hxx"
#include "SingleMode.hxx"
#include "ConsumeMode.hxx"
#include "Chrono.hxx"
#include "config.h"
#include <boost/intrusive/list.hpp>
#include <string>
#include <memory>
@ -47,6 +46,7 @@ class MultipleOutputs;
class SongLoader;
class ClientListener;
class Client;
struct ClientPerPartitionListHook;
/**
* A partition of the Music Player Daemon. It is a separate unit with
@ -65,10 +65,7 @@ struct Partition final : QueueListener, PlayerListener, MixerListener {
std::unique_ptr<ClientListener> listener;
boost::intrusive::list<Client,
boost::intrusive::base_hook<boost::intrusive::list_base_hook<boost::intrusive::tag<Partition>,
boost::intrusive::link_mode<boost::intrusive::normal_link>>>,
boost::intrusive::constant_time_size<false>> clients;
IntrusiveList<Client, ClientPerPartitionListHook, false> clients;
/**
* Monitor for idle events local to this partition.

View File

@ -27,9 +27,7 @@
#include "tag/Mask.hxx"
#include "event/FullyBufferedSocket.hxx"
#include "event/CoarseTimerEvent.hxx"
#include <boost/intrusive/link_mode.hpp>
#include <boost/intrusive/list_hook.hpp>
#include "util/IntrusiveList.hxx"
#include <cstddef>
#include <list>
@ -50,10 +48,13 @@ class Storage;
class BackgroundCommand;
class Client final
: FullyBufferedSocket,
public boost::intrusive::list_base_hook<boost::intrusive::tag<Partition>,
boost::intrusive::link_mode<boost::intrusive::normal_link>>,
public boost::intrusive::list_base_hook<boost::intrusive::link_mode<boost::intrusive::normal_link>> {
: FullyBufferedSocket
{
friend struct ClientPerPartitionListHook;
friend class ClientList;
IntrusiveListHook list_siblings, partition_siblings;
CoarseTimerEvent timeout_event;
Partition *partition;
@ -295,6 +296,9 @@ private:
void OnTimeout() noexcept;
};
struct ClientPerPartitionListHook
: IntrusiveListMemberHookTraits<&Client::partition_siblings> {};
void
client_new(EventLoop &loop, Partition &partition,
UniqueSocketDescriptor fd, SocketAddress address, int uid,

View File

@ -21,13 +21,11 @@
#define MPD_CLIENT_LIST_HXX
#include "Client.hxx"
#include <boost/intrusive/list.hpp>
#include "util/IntrusiveList.hxx"
class ClientList {
using List =
boost::intrusive::list<Client,
boost::intrusive::constant_time_size<true>>;
IntrusiveList<Client, IntrusiveListMemberHookTraits<&Client::list_siblings>, true>;
const unsigned max_size;