thread/Mutex: remove ScopeLock, use std::lock_guard directly
This commit is contained in:
@@ -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