lib/upnp/Discovery: add noexcept

This commit is contained in:
Max Kellermann 2024-01-04 20:37:34 +01:00
parent 468eceabff
commit 22382f799c
2 changed files with 12 additions and 10 deletions

View File

@ -174,7 +174,7 @@ isMSDevice(std::string_view st) noexcept
} }
static void static void
AnnounceFoundUPnP(UPnPDiscoveryListener &listener, const UPnPDevice &device) AnnounceFoundUPnP(UPnPDiscoveryListener &listener, const UPnPDevice &device) noexcept
{ {
for (const auto &service : device.services) for (const auto &service : device.services)
if (isCDService(service.serviceType)) if (isCDService(service.serviceType))
@ -183,7 +183,7 @@ AnnounceFoundUPnP(UPnPDiscoveryListener &listener, const UPnPDevice &device)
} }
static void static void
AnnounceLostUPnP(UPnPDiscoveryListener &listener, const UPnPDevice &device) AnnounceLostUPnP(UPnPDiscoveryListener &listener, const UPnPDevice &device) noexcept
{ {
for (const auto &service : device.services) for (const auto &service : device.services)
if (isCDService(service.serviceType)) if (isCDService(service.serviceType))
@ -192,7 +192,7 @@ AnnounceLostUPnP(UPnPDiscoveryListener &listener, const UPnPDevice &device)
} }
inline void inline void
UPnPDeviceDirectory::LockAdd(ContentDirectoryDescriptor &&d) UPnPDeviceDirectory::LockAdd(ContentDirectoryDescriptor &&d) noexcept
{ {
const std::scoped_lock<Mutex> protect(mutex); const std::scoped_lock<Mutex> protect(mutex);
@ -210,7 +210,7 @@ UPnPDeviceDirectory::LockAdd(ContentDirectoryDescriptor &&d)
} }
inline void inline void
UPnPDeviceDirectory::LockRemove(const std::string &id) UPnPDeviceDirectory::LockRemove(const std::string &id) noexcept
{ {
const std::scoped_lock<Mutex> protect(mutex); const std::scoped_lock<Mutex> protect(mutex);
@ -285,7 +285,7 @@ UPnPDeviceDirectory::Invoke(Upnp_EventType et, const void *evp) noexcept
} }
void void
UPnPDeviceDirectory::ExpireDevices() UPnPDeviceDirectory::ExpireDevices() noexcept
{ {
const auto now = std::chrono::steady_clock::now(); const auto now = std::chrono::steady_clock::now();
bool didsomething = false; bool didsomething = false;
@ -350,7 +350,7 @@ UPnPDeviceDirectory::Search()
} }
std::vector<ContentDirectoryService> std::vector<ContentDirectoryService>
UPnPDeviceDirectory::GetDirectories() UPnPDeviceDirectory::GetDirectories() noexcept
{ {
const std::scoped_lock<Mutex> protect(mutex); const std::scoped_lock<Mutex> protect(mutex);

View File

@ -71,12 +71,14 @@ public:
UPnPDeviceDirectory(const UPnPDeviceDirectory &) = delete; UPnPDeviceDirectory(const UPnPDeviceDirectory &) = delete;
UPnPDeviceDirectory& operator=(const UPnPDeviceDirectory &) = delete; UPnPDeviceDirectory& operator=(const UPnPDeviceDirectory &) = delete;
[[gnu::const]]
EventLoop &GetEventLoop() const noexcept; EventLoop &GetEventLoop() const noexcept;
void Start(); void Start();
/** Retrieve the directory services currently seen on the network */ /** Retrieve the directory services currently seen on the network */
std::vector<ContentDirectoryService> GetDirectories(); [[gnu::pure]]
std::vector<ContentDirectoryService> GetDirectories() noexcept;
/** /**
* Get server by friendly name. * Get server by friendly name.
@ -93,10 +95,10 @@ private:
* *
* Caller must lock #mutex. * Caller must lock #mutex.
*/ */
void ExpireDevices(); void ExpireDevices() noexcept;
void LockAdd(ContentDirectoryDescriptor &&d); void LockAdd(ContentDirectoryDescriptor &&d) noexcept;
void LockRemove(const std::string &id); void LockRemove(const std::string &id) noexcept;
int OnAlive(const UpnpDiscovery *disco) noexcept; int OnAlive(const UpnpDiscovery *disco) noexcept;
int OnByeBye(const UpnpDiscovery *disco) noexcept; int OnByeBye(const UpnpDiscovery *disco) noexcept;