AzeorthCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Acore::SignalHandler Class Reference

Handle termination signals. More...

#include "SignalHandler.h"

Public Member Functions

bool handle_signal (int sig, void(*func)(int))
 
 ~SignalHandler ()
 

Private Attributes

std::unordered_set< int > _handled
 
std::mutex _mutex
 

Detailed Description

Handle termination signals.

Constructor & Destructor Documentation

◆ ~SignalHandler()

Acore::SignalHandler::~SignalHandler ( )
inline
50 {
51 for (auto const& sig : _handled)
52 {
53 signal(sig, nullptr);
54 }
55 }
std::unordered_set< int > _handled
Definition: SignalHandler.h:31

References _handled.

Member Function Documentation

◆ handle_signal()

bool Acore::SignalHandler::handle_signal ( int  sig,
void(*)(int)  func 
)
inline
36 {
37 std::lock_guard lock(_mutex);
38
39 if (_handled.find(sig) != _handled.end())
40 {
41 return false;
42 }
43
44 _handled.insert(sig);
45 signal(sig, func);
46 return true;
47 }
std::mutex _mutex
Definition: SignalHandler.h:32

References _handled, and _mutex.

Member Data Documentation

◆ _handled

std::unordered_set<int> Acore::SignalHandler::_handled
private

Referenced by handle_signal(), and ~SignalHandler().

◆ _mutex

std::mutex Acore::SignalHandler::_mutex
mutableprivate

Referenced by handle_signal().