libnick 2025.9.1
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
suspendinhibitor.h
Go to the documentation of this file.
1
22
23#ifndef SUSPENDINHIBITOR_H
24#define SUSPENDINHIBITOR_H
25
26#include <mutex>
27#ifdef __APPLE__
28#include <IOKit/pwr_mgt/IOPMLib.h>
29#endif
30
31namespace Nickvision::System
32{
37 {
38 public:
43 SuspendInhibitor() noexcept;
48 SuspendInhibitor(const SuspendInhibitor& other) noexcept;
58 ~SuspendInhibitor() noexcept;
63 bool isInhibiting() const noexcept;
68 bool inhibit() noexcept;
73 bool uninhibit() noexcept;
79 SuspendInhibitor& operator=(const SuspendInhibitor& other) noexcept;
85 SuspendInhibitor& operator=(SuspendInhibitor&& other) noexcept;
86
87 private:
88 mutable std::mutex m_mutex;
89 bool m_inhibiting;
90#ifdef __linux__
91 unsigned int m_cookie;
92#elif defined(__APPLE__)
93 IOPMAssertionID m_cookie;
94#endif
95 };
96}
97
98#endif //SUSPENDINHIBITOR_H
bool isInhibiting() const noexcept
Gets whether or not the system is being inhibited from suspending.
bool inhibit() noexcept
Inhibits the system from suspending.
SuspendInhibitor() noexcept
Constructs a SuspendInhibitor.
bool uninhibit() noexcept
Uninhibits the system from suspending.
Definition credentials.h:31