From 0a0cc66e8f9eb1646b54262cf233fc8ce20389af Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 7 May 2019 19:23:01 +0200 Subject: [PATCH] thread/Mutex: use `using` instead of making it a derived class Prepare the transition to std::mutex. --- src/archive/ArchiveFile.hxx | 4 ++-- src/input/InputPlugin.hxx | 2 +- src/input/LocalOpen.hxx | 2 +- src/input/plugins/ArchiveInputPlugin.hxx | 2 +- src/input/plugins/CurlInputPlugin.hxx | 3 +-- src/input/plugins/FileInputPlugin.hxx | 2 +- src/lib/curl/Init.hxx | 5 +++-- src/lib/smbclient/Mutex.cxx | 1 - src/lib/smbclient/Mutex.hxx | 2 +- src/output/Control.hxx | 1 - src/output/Source.hxx | 2 +- src/playlist/PlaylistAny.hxx | 2 +- src/playlist/PlaylistMapper.hxx | 2 +- src/playlist/PlaylistPlugin.hxx | 2 +- src/playlist/PlaylistRegistry.hxx | 2 +- src/playlist/PlaylistStream.hxx | 2 +- src/tag/Aiff.hxx | 3 +-- src/tag/Riff.hxx | 3 +-- src/thread/Mutex.hxx | 4 ++-- 19 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/archive/ArchiveFile.hxx b/src/archive/ArchiveFile.hxx index 5a1cdf516..9468a1008 100644 --- a/src/archive/ArchiveFile.hxx +++ b/src/archive/ArchiveFile.hxx @@ -1,5 +1,5 @@ /* - * Copyright 2003-2018 The Music Player Daemon Project + * Copyright 2003-2019 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -21,8 +21,8 @@ #define MPD_ARCHIVE_FILE_HXX #include "input/Ptr.hxx" +#include "thread/Mutex.hxx" -class Mutex; class ArchiveVisitor; class ArchiveFile { diff --git a/src/input/InputPlugin.hxx b/src/input/InputPlugin.hxx index 51b44c061..27e45009c 100644 --- a/src/input/InputPlugin.hxx +++ b/src/input/InputPlugin.hxx @@ -21,10 +21,10 @@ #define MPD_INPUT_PLUGIN_HXX #include "Ptr.hxx" +#include "thread/Mutex.hxx" #include "util/Compiler.h" struct ConfigBlock; -class Mutex; class EventLoop; class RemoteTagScanner; class RemoteTagHandler; diff --git a/src/input/LocalOpen.hxx b/src/input/LocalOpen.hxx index 0b58f443f..ada0b998a 100644 --- a/src/input/LocalOpen.hxx +++ b/src/input/LocalOpen.hxx @@ -21,9 +21,9 @@ #define MPD_INPUT_LOCAL_OPEN_HXX #include "Ptr.hxx" +#include "thread/Mutex.hxx" class Path; -class Mutex; /** * Open a "local" file. This is a wrapper for the input plugins diff --git a/src/input/plugins/ArchiveInputPlugin.hxx b/src/input/plugins/ArchiveInputPlugin.hxx index 00cd09ce2..9568628fd 100644 --- a/src/input/plugins/ArchiveInputPlugin.hxx +++ b/src/input/plugins/ArchiveInputPlugin.hxx @@ -21,9 +21,9 @@ #define MPD_INPUT_ARCHIVE_HXX #include "input/Ptr.hxx" +#include "thread/Mutex.hxx" class Path; -class Mutex; InputStreamPtr OpenArchiveInputStream(Path path, Mutex &mutex); diff --git a/src/input/plugins/CurlInputPlugin.hxx b/src/input/plugins/CurlInputPlugin.hxx index 2efa004fd..baf99fb3c 100644 --- a/src/input/plugins/CurlInputPlugin.hxx +++ b/src/input/plugins/CurlInputPlugin.hxx @@ -21,12 +21,11 @@ #define MPD_INPUT_CURL_HXX #include "input/Ptr.hxx" +#include "thread/Mutex.hxx" #include #include -class Mutex; - extern const struct InputPlugin input_plugin_curl; /** diff --git a/src/input/plugins/FileInputPlugin.hxx b/src/input/plugins/FileInputPlugin.hxx index 97f7f2a62..22f676f61 100644 --- a/src/input/plugins/FileInputPlugin.hxx +++ b/src/input/plugins/FileInputPlugin.hxx @@ -21,9 +21,9 @@ #define MPD_INPUT_FILE_HXX #include "input/Ptr.hxx" +#include "thread/Mutex.hxx" class Path; -class Mutex; InputStreamPtr OpenFileInputStream(Path path, Mutex &mutex); diff --git a/src/lib/curl/Init.hxx b/src/lib/curl/Init.hxx index 4256f2603..ee2da9dbd 100644 --- a/src/lib/curl/Init.hxx +++ b/src/lib/curl/Init.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2017 Max Kellermann + * Copyright 2008-2019 Max Kellermann * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,7 +30,8 @@ #ifndef CURL_INIT_HXX #define CURL_INIT_HXX -class Mutex; +#include "thread/Mutex.hxx" + class EventLoop; class CurlGlobal; diff --git a/src/lib/smbclient/Mutex.cxx b/src/lib/smbclient/Mutex.cxx index 6ba6aaff3..3d1dfb58c 100644 --- a/src/lib/smbclient/Mutex.cxx +++ b/src/lib/smbclient/Mutex.cxx @@ -18,6 +18,5 @@ */ #include "Mutex.hxx" -#include "thread/Mutex.hxx" Mutex smbclient_mutex; diff --git a/src/lib/smbclient/Mutex.hxx b/src/lib/smbclient/Mutex.hxx index 4a9ba54fb..05352bada 100644 --- a/src/lib/smbclient/Mutex.hxx +++ b/src/lib/smbclient/Mutex.hxx @@ -20,7 +20,7 @@ #ifndef MPD_SMBCLIENT_MUTEX_HXX #define MPD_SMBCLIENT_MUTEX_HXX -class Mutex; +#include "thread/Mutex.hxx" /** * Since libsmbclient is not thread-safe, this mutex must be locked diff --git a/src/output/Control.hxx b/src/output/Control.hxx index eb61cdf77..4610f2034 100644 --- a/src/output/Control.hxx +++ b/src/output/Control.hxx @@ -45,7 +45,6 @@ struct FilteredAudioOutput; struct MusicChunk; struct ConfigBlock; class MusicPipe; -class Mutex; class Mixer; class AudioOutputClient; diff --git a/src/output/Source.hxx b/src/output/Source.hxx index a2b04a8e4..817dd27a4 100644 --- a/src/output/Source.hxx +++ b/src/output/Source.hxx @@ -26,6 +26,7 @@ #include "ReplayGainMode.hxx" #include "pcm/PcmBuffer.hxx" #include "pcm/PcmDither.hxx" +#include "thread/Mutex.hxx" #include "util/ConstBuffer.hxx" #include @@ -36,7 +37,6 @@ struct MusicChunk; struct Tag; -class Mutex; class Filter; class PreparedFilter; diff --git a/src/playlist/PlaylistAny.hxx b/src/playlist/PlaylistAny.hxx index 318e78f4a..84b8837ca 100644 --- a/src/playlist/PlaylistAny.hxx +++ b/src/playlist/PlaylistAny.hxx @@ -20,11 +20,11 @@ #ifndef MPD_PLAYLIST_ANY_HXX #define MPD_PLAYLIST_ANY_HXX +#include "thread/Mutex.hxx" #include "config.h" #include -class Mutex; class SongEnumerator; class Storage; diff --git a/src/playlist/PlaylistMapper.hxx b/src/playlist/PlaylistMapper.hxx index d4e5072f5..cb1af5d23 100644 --- a/src/playlist/PlaylistMapper.hxx +++ b/src/playlist/PlaylistMapper.hxx @@ -20,11 +20,11 @@ #ifndef MPD_PLAYLIST_MAPPER_HXX #define MPD_PLAYLIST_MAPPER_HXX +#include "thread/Mutex.hxx" #include "config.h" #include -class Mutex; class SongEnumerator; class Storage; diff --git a/src/playlist/PlaylistPlugin.hxx b/src/playlist/PlaylistPlugin.hxx index 635940f9d..ea285c35a 100644 --- a/src/playlist/PlaylistPlugin.hxx +++ b/src/playlist/PlaylistPlugin.hxx @@ -21,10 +21,10 @@ #define MPD_PLAYLIST_PLUGIN_HXX #include "input/Ptr.hxx" +#include "thread/Mutex.hxx" struct ConfigBlock; struct Tag; -class Mutex; class SongEnumerator; struct playlist_plugin { diff --git a/src/playlist/PlaylistRegistry.hxx b/src/playlist/PlaylistRegistry.hxx index 7cd6fb348..62beb01b4 100644 --- a/src/playlist/PlaylistRegistry.hxx +++ b/src/playlist/PlaylistRegistry.hxx @@ -21,10 +21,10 @@ #define MPD_PLAYLIST_REGISTRY_HXX #include "input/Ptr.hxx" +#include "thread/Mutex.hxx" #include "util/Compiler.h" struct ConfigData; -class Mutex; class SongEnumerator; extern const struct playlist_plugin *const playlist_plugins[]; diff --git a/src/playlist/PlaylistStream.hxx b/src/playlist/PlaylistStream.hxx index 8ad1ac647..de796d819 100644 --- a/src/playlist/PlaylistStream.hxx +++ b/src/playlist/PlaylistStream.hxx @@ -20,11 +20,11 @@ #ifndef MPD_PLAYLIST_STREAM_HXX #define MPD_PLAYLIST_STREAM_HXX +#include "thread/Mutex.hxx" #include "util/Compiler.h" #include -class Mutex; class SongEnumerator; class Path; diff --git a/src/tag/Aiff.hxx b/src/tag/Aiff.hxx index eb59afe71..6600294ca 100644 --- a/src/tag/Aiff.hxx +++ b/src/tag/Aiff.hxx @@ -25,12 +25,11 @@ #ifndef MPD_AIFF_HXX #define MPD_AIFF_HXX -#include +#include "thread/Mutex.hxx" #include class InputStream; -class Mutex; /** * Seeks the AIFF file to the ID3 chunk. diff --git a/src/tag/Riff.hxx b/src/tag/Riff.hxx index 4a1aac45d..6e556eded 100644 --- a/src/tag/Riff.hxx +++ b/src/tag/Riff.hxx @@ -25,11 +25,10 @@ #ifndef MPD_RIFF_HXX #define MPD_RIFF_HXX -#include +#include "thread/Mutex.hxx" #include -class Mutex; class InputStream; /** diff --git a/src/thread/Mutex.hxx b/src/thread/Mutex.hxx index f1aa03cb2..a28bb13a7 100644 --- a/src/thread/Mutex.hxx +++ b/src/thread/Mutex.hxx @@ -35,12 +35,12 @@ #ifdef _WIN32 #include "CriticalSection.hxx" -class Mutex : public CriticalSection {}; +using Mutex = CriticalSection; #else #include "PosixMutex.hxx" -class Mutex : public PosixMutex {}; +using Mutex = PosixMutex; #endif