[vlc-commits] gui/qt: add struct vlc_playlist_locker
Filip Roséen
git at videolan.org
Wed Jul 20 16:15:54 CEST 2016
vlc | branch: master | Filip Roséen <filip at videolabs.io> | Wed Jul 20 04:36:52 2016 +0200| [e7986497fe532eeb17194a3e69eec53c2055b8b8] | committer: Jean-Baptiste Kempf
gui/qt: add struct vlc_playlist_locker
Given that we currently do not have such entity in
include/vlc_playlist.h, this patch introduces such inside the
gui/Qt-module.
The perks of using this helper are:
1. it makes locking/unlocking the playlist thread-safe
2. it makes it "impossible" to forget to unlock the playlist
3. it often makes it easier to reason about the code
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e7986497fe532eeb17194a3e69eec53c2055b8b8
---
modules/gui/qt/qt.hpp | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/modules/gui/qt/qt.hpp b/modules/gui/qt/qt.hpp
index 0b83f1f..7276bdc 100644
--- a/modules/gui/qt/qt.hpp
+++ b/modules/gui/qt/qt.hpp
@@ -98,6 +98,29 @@ struct intf_sys_t
#define THEPL p_intf->p_sys->p_playlist
+/**
+ * This class may be used for scope-bound locking/unlocking
+ * of a playlist_t*. As hinted, the playlist is locked when
+ * the object is created, and unlocked when the object is
+ * destroyed.
+ */
+
+struct vlc_playlist_locker {
+ vlc_playlist_locker( playlist_t* p_playlist )
+ : p_playlist( p_playlist )
+ {
+ playlist_Lock( p_playlist );
+ }
+
+ ~vlc_playlist_locker()
+ {
+ playlist_Unlock( p_playlist );
+ }
+
+ private:
+ playlist_t* p_playlist;
+};
+
#define THEDP DialogsProvider::getInstance()
#define THEMIM MainInputManager::getInstance( p_intf )
#define THEAM ActionsManager::getInstance( p_intf )
More information about the vlc-commits
mailing list