aboutsummaryrefslogtreecommitdiffstats
path: root/src/db/plugins/simple/Song.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-06-10 21:15:40 +0200
committerMax Kellermann <max@duempel.org>2014-06-16 18:39:16 +0200
commit3ca0a39a357d9be9c85de4892ac02716f8af2ae8 (patch)
tree88c87573974f6609a1dc68cf20e5901600613280 /src/db/plugins/simple/Song.hxx
parent52594e64d0f48eb83c9bf54eb1ac95a6de881829 (diff)
downloadmpd-3ca0a39a357d9be9c85de4892ac02716f8af2ae8.tar.gz
mpd-3ca0a39a357d9be9c85de4892ac02716f8af2ae8.tar.xz
mpd-3ca0a39a357d9be9c85de4892ac02716f8af2ae8.zip
db/simple: use class boost::intrusive::list
Remove the C list_head library and use type-safe C++ instead.
Diffstat (limited to 'src/db/plugins/simple/Song.hxx')
-rw-r--r--src/db/plugins/simple/Song.hxx20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/db/plugins/simple/Song.hxx b/src/db/plugins/simple/Song.hxx
index 75fce20e9..b2e85aa6b 100644
--- a/src/db/plugins/simple/Song.hxx
+++ b/src/db/plugins/simple/Song.hxx
@@ -20,10 +20,11 @@
#ifndef MPD_SONG_HXX
#define MPD_SONG_HXX
-#include "util/list.h"
#include "tag/Tag.hxx"
#include "Compiler.h"
+#include <boost/intrusive/list.hpp>
+
#include <string>
#include <assert.h>
@@ -39,6 +40,16 @@ class Storage;
* #SimpleDatabase class.
*/
struct Song {
+ static constexpr auto link_mode = boost::intrusive::normal_link;
+ typedef boost::intrusive::link_mode<link_mode> LinkMode;
+ typedef boost::intrusive::list_member_hook<LinkMode> Hook;
+
+ struct Disposer {
+ void operator()(Song *song) const {
+ song->Free();
+ }
+ };
+
/**
* Pointers to the siblings of this directory within the
* parent directory. It is unused (undefined) if this song is
@@ -47,7 +58,7 @@ struct Song {
* This attribute is protected with the global #db_mutex.
* Read access in the update thread does not need protection.
*/
- struct list_head siblings;
+ Hook siblings;
Tag tag;
@@ -110,4 +121,9 @@ struct Song {
LightSong Export() const;
};
+typedef boost::intrusive::list<Song,
+ boost::intrusive::member_hook<Song, Song::Hook,
+ &Song::siblings>,
+ boost::intrusive::constant_time_size<false>> SongList;
+
#endif