thread/Mutex: remove ScopeLock, use std::lock_guard directly
This commit is contained in:
@@ -105,7 +105,7 @@ AllocatedString<char>
|
||||
IcuConverter::ToUTF8(const char *s) const
|
||||
{
|
||||
#ifdef HAVE_ICU
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
ucnv_resetToUnicode(converter);
|
||||
|
||||
@@ -133,7 +133,7 @@ AllocatedString<char>
|
||||
IcuConverter::FromUTF8(const char *s) const
|
||||
{
|
||||
#ifdef HAVE_ICU
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
const auto u = UCharFromUTF8(s);
|
||||
|
||||
|
@@ -60,7 +60,7 @@ public:
|
||||
|
||||
private:
|
||||
bool LockWaitFinished() {
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
while (!finished)
|
||||
if (!cond.timed_wait(mutex, timeout))
|
||||
return false;
|
||||
@@ -73,7 +73,7 @@ private:
|
||||
* thread.
|
||||
*/
|
||||
void LockSetFinished() {
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
finished = true;
|
||||
cond.signal();
|
||||
}
|
||||
|
@@ -43,7 +43,7 @@ mpd_smbc_get_auth_data(gcc_unused const char *srv,
|
||||
void
|
||||
SmbclientInit()
|
||||
{
|
||||
const ScopeLock protect(smbclient_mutex);
|
||||
const std::lock_guard<Mutex> protect(smbclient_mutex);
|
||||
|
||||
constexpr int debug = 0;
|
||||
if (smbc_init(mpd_smbc_get_auth_data, debug) < 0)
|
||||
|
@@ -61,7 +61,7 @@ UpnpClientGlobalInit(UpnpClient_Handle &handle)
|
||||
UpnpGlobalInit();
|
||||
|
||||
try {
|
||||
const ScopeLock protect(upnp_client_init_mutex);
|
||||
const std::lock_guard<Mutex> protect(upnp_client_init_mutex);
|
||||
if (upnp_client_ref == 0)
|
||||
DoInit();
|
||||
} catch (...) {
|
||||
@@ -77,7 +77,7 @@ void
|
||||
UpnpClientGlobalFinish()
|
||||
{
|
||||
{
|
||||
const ScopeLock protect(upnp_client_init_mutex);
|
||||
const std::lock_guard<Mutex> protect(upnp_client_init_mutex);
|
||||
|
||||
assert(upnp_client_ref > 0);
|
||||
if (--upnp_client_ref == 0)
|
||||
|
@@ -74,7 +74,7 @@ AnnounceLostUPnP(UPnPDiscoveryListener &listener, const UPnPDevice &device)
|
||||
inline void
|
||||
UPnPDeviceDirectory::LockAdd(ContentDirectoryDescriptor &&d)
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
for (auto &i : directories) {
|
||||
if (i.id == d.id) {
|
||||
@@ -92,7 +92,7 @@ UPnPDeviceDirectory::LockAdd(ContentDirectoryDescriptor &&d)
|
||||
inline void
|
||||
UPnPDeviceDirectory::LockRemove(const std::string &id)
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
for (auto i = directories.begin(), end = directories.end();
|
||||
i != end; ++i) {
|
||||
@@ -273,7 +273,7 @@ UPnPDeviceDirectory::Search()
|
||||
std::vector<ContentDirectoryService>
|
||||
UPnPDeviceDirectory::GetDirectories()
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
ExpireDevices();
|
||||
|
||||
@@ -293,7 +293,7 @@ UPnPDeviceDirectory::GetDirectories()
|
||||
ContentDirectoryService
|
||||
UPnPDeviceDirectory::GetServer(const char *friendly_name)
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
ExpireDevices();
|
||||
|
||||
|
@@ -48,7 +48,7 @@ DoInit()
|
||||
void
|
||||
UpnpGlobalInit()
|
||||
{
|
||||
const ScopeLock protect(upnp_init_mutex);
|
||||
const std::lock_guard<Mutex> protect(upnp_init_mutex);
|
||||
|
||||
if (upnp_ref == 0)
|
||||
DoInit();
|
||||
@@ -59,7 +59,7 @@ UpnpGlobalInit()
|
||||
void
|
||||
UpnpGlobalFinish()
|
||||
{
|
||||
const ScopeLock protect(upnp_init_mutex);
|
||||
const std::lock_guard<Mutex> protect(upnp_init_mutex);
|
||||
|
||||
assert(upnp_ref > 0);
|
||||
|
||||
|
@@ -90,7 +90,7 @@ public:
|
||||
*/
|
||||
bool start(unsigned nworkers, void *(*workproc)(void *), void *arg)
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
assert(nworkers > 0);
|
||||
assert(!ok);
|
||||
@@ -120,7 +120,7 @@ public:
|
||||
template<typename U>
|
||||
bool put(U &&u)
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
queue.emplace(std::forward<U>(u));
|
||||
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
*/
|
||||
void setTerminateAndWait()
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
// Wait for all worker threads to have called workerExit()
|
||||
ok = false;
|
||||
@@ -166,7 +166,7 @@ public:
|
||||
*/
|
||||
bool take(T &tp)
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
if (!ok)
|
||||
return false;
|
||||
@@ -192,7 +192,7 @@ public:
|
||||
*/
|
||||
void workerExit()
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
n_workers_exited++;
|
||||
ok = false;
|
||||
|
Reference in New Issue
Block a user