db/simple/{Directory,Song}: use IntrusiveList instead of boost::intrusive::list
This commit is contained in:
parent
a448d04d46
commit
81e1f87e8c
@ -31,6 +31,7 @@
|
|||||||
#include "lib/icu/Collate.hxx"
|
#include "lib/icu/Collate.hxx"
|
||||||
#include "fs/Traits.hxx"
|
#include "fs/Traits.hxx"
|
||||||
#include "util/DeleteDisposer.hxx"
|
#include "util/DeleteDisposer.hxx"
|
||||||
|
#include "util/SortList.hxx"
|
||||||
#include "util/StringCompare.hxx"
|
#include "util/StringCompare.hxx"
|
||||||
#include "util/StringSplit.hxx"
|
#include "util/StringSplit.hxx"
|
||||||
|
|
||||||
@ -220,7 +221,7 @@ Directory::Sort() noexcept
|
|||||||
{
|
{
|
||||||
assert(holding_db_lock());
|
assert(holding_db_lock());
|
||||||
|
|
||||||
children.sort(directory_cmp);
|
SortList(children, directory_cmp);
|
||||||
song_list_sort(songs);
|
song_list_sort(songs);
|
||||||
|
|
||||||
for (auto &child : children)
|
for (auto &child : children)
|
||||||
|
@ -24,9 +24,7 @@
|
|||||||
#include "db/Visitor.hxx"
|
#include "db/Visitor.hxx"
|
||||||
#include "db/PlaylistVector.hxx"
|
#include "db/PlaylistVector.hxx"
|
||||||
#include "db/Ptr.hxx"
|
#include "db/Ptr.hxx"
|
||||||
#include "Song.hxx"
|
#include "util/IntrusiveList.hxx"
|
||||||
|
|
||||||
#include <boost/intrusive/list.hpp>
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
@ -52,25 +50,12 @@ static constexpr unsigned DEVICE_PLAYLIST = -3;
|
|||||||
|
|
||||||
class SongFilter;
|
class SongFilter;
|
||||||
|
|
||||||
struct Directory {
|
struct Directory : IntrusiveListHook {
|
||||||
static constexpr auto link_mode = boost::intrusive::normal_link;
|
/* Note: the #IntrusiveListHook is protected with the global
|
||||||
typedef boost::intrusive::link_mode<link_mode> LinkMode;
|
#db_mutex. Read access in the update thread does not need
|
||||||
typedef boost::intrusive::list_member_hook<LinkMode> Hook;
|
protection. */
|
||||||
|
|
||||||
/**
|
using List = IntrusiveList<Directory>;
|
||||||
* Pointers to the siblings of this directory within the
|
|
||||||
* parent directory. It is unused (undefined) in the root
|
|
||||||
* directory.
|
|
||||||
*
|
|
||||||
* This attribute is protected with the global #db_mutex.
|
|
||||||
* Read access in the update thread does not need protection.
|
|
||||||
*/
|
|
||||||
Hook siblings;
|
|
||||||
|
|
||||||
typedef boost::intrusive::member_hook<Directory, Hook,
|
|
||||||
&Directory::siblings> SiblingsHook;
|
|
||||||
typedef boost::intrusive::list<Directory, SiblingsHook,
|
|
||||||
boost::intrusive::constant_time_size<false>> List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A doubly linked list of child directories.
|
* A doubly linked list of child directories.
|
||||||
@ -86,7 +71,7 @@ struct Directory {
|
|||||||
* This attribute is protected with the global #db_mutex.
|
* This attribute is protected with the global #db_mutex.
|
||||||
* Read access in the update thread does not need protection.
|
* Read access in the update thread does not need protection.
|
||||||
*/
|
*/
|
||||||
SongList songs;
|
IntrusiveList<Song> songs;
|
||||||
|
|
||||||
PlaylistVector playlists;
|
PlaylistVector playlists;
|
||||||
|
|
||||||
|
@ -24,10 +24,9 @@
|
|||||||
#include "Chrono.hxx"
|
#include "Chrono.hxx"
|
||||||
#include "tag/Tag.hxx"
|
#include "tag/Tag.hxx"
|
||||||
#include "pcm/AudioFormat.hxx"
|
#include "pcm/AudioFormat.hxx"
|
||||||
|
#include "util/IntrusiveList.hxx"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <boost/intrusive/list.hpp>
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
struct Directory;
|
struct Directory;
|
||||||
@ -40,20 +39,10 @@ class ArchiveFile;
|
|||||||
* A song file inside the configured music directory. Internal
|
* A song file inside the configured music directory. Internal
|
||||||
* #SimpleDatabase class.
|
* #SimpleDatabase class.
|
||||||
*/
|
*/
|
||||||
struct Song {
|
struct Song : IntrusiveListHook {
|
||||||
static constexpr auto link_mode = boost::intrusive::normal_link;
|
/* Note: the #IntrusiveListHook is protected with the global
|
||||||
typedef boost::intrusive::link_mode<link_mode> LinkMode;
|
#db_mutex. Read access in the update thread does not need
|
||||||
typedef boost::intrusive::list_member_hook<LinkMode> Hook;
|
protection. */
|
||||||
|
|
||||||
/**
|
|
||||||
* Pointers to the siblings of this directory within the
|
|
||||||
* parent directory. It is unused (undefined) if this song is
|
|
||||||
* not in the database.
|
|
||||||
*
|
|
||||||
* This attribute is protected with the global #db_mutex.
|
|
||||||
* Read access in the update thread does not need protection.
|
|
||||||
*/
|
|
||||||
Hook siblings;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The #Directory that contains this song.
|
* The #Directory that contains this song.
|
||||||
@ -160,9 +149,4 @@ struct Song {
|
|||||||
ExportedSong Export() const noexcept;
|
ExportedSong Export() const noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef boost::intrusive::list<Song,
|
|
||||||
boost::intrusive::member_hook<Song, Song::Hook,
|
|
||||||
&Song::siblings>,
|
|
||||||
boost::intrusive::constant_time_size<false>> SongList;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#include "Song.hxx"
|
#include "Song.hxx"
|
||||||
#include "tag/Tag.hxx"
|
#include "tag/Tag.hxx"
|
||||||
#include "lib/icu/Collate.hxx"
|
#include "lib/icu/Collate.hxx"
|
||||||
|
#include "util/IntrusiveList.hxx"
|
||||||
|
#include "util/SortList.hxx"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
@ -100,7 +102,7 @@ song_cmp(const Song &a, const Song &b) noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
song_list_sort(SongList &songs) noexcept
|
song_list_sort(IntrusiveList<Song> &songs) noexcept
|
||||||
{
|
{
|
||||||
songs.sort(song_cmp);
|
SortList(songs, song_cmp);
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,11 @@
|
|||||||
#ifndef MPD_SONG_SORT_HXX
|
#ifndef MPD_SONG_SORT_HXX
|
||||||
#define MPD_SONG_SORT_HXX
|
#define MPD_SONG_SORT_HXX
|
||||||
|
|
||||||
#include "Song.hxx"
|
#include "util/IntrusiveList.hxx"
|
||||||
|
|
||||||
|
struct Song;
|
||||||
|
|
||||||
void
|
void
|
||||||
song_list_sort(SongList &songs) noexcept;
|
song_list_sort(IntrusiveList<Song> &songs) noexcept;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "db/DatabaseLock.hxx"
|
#include "db/DatabaseLock.hxx"
|
||||||
#include "db/PlaylistVector.hxx"
|
#include "db/PlaylistVector.hxx"
|
||||||
#include "db/plugins/simple/Directory.hxx"
|
#include "db/plugins/simple/Directory.hxx"
|
||||||
|
#include "db/plugins/simple/Song.hxx"
|
||||||
#include "lib/fmt/ExceptionFormatter.hxx"
|
#include "lib/fmt/ExceptionFormatter.hxx"
|
||||||
#include "song/DetachedSong.hxx"
|
#include "song/DetachedSong.hxx"
|
||||||
#include "input/InputStream.hxx"
|
#include "input/InputStream.hxx"
|
||||||
|
Loading…
Reference in New Issue
Block a user