Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
SignalHandlers.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
5
7
8 /*
9 ********************************************************************************
10 ******************************** SignalHandler *********************************
11 ********************************************************************************
12 */
13 inline SignalHandler::SignalHandler (void (*signalHandler) (SignalID), Type type)
14 : fType_{type}
15 , fCall_{signalHandler}
16 {
17 Require (signalHandler == SIG_IGN or type == Type::eSafe); // otherwise use the overload taking a noexcept function
18 }
19 inline SignalHandler::SignalHandler (void (*signalHandler) (SignalID) noexcept, Type type)
20 : fType_{type}
21 , fCall_{signalHandler}
22 {
23 }
24 inline SignalHandler::SignalHandler (const Function<void (SignalID)>& signalHandler, Type type)
25 : fType_{type}
26 , fCall_{signalHandler}
27 {
28 // @todo - would LIKE to overload this CTOR like we do for regular function pointer, noexcept and noexcept(false), but
29 // that doesn't appear to work wtih std::function as of C++17 (reference?) -- DISABLE this Require()
30 // Require (type == Type::eSafe); // otherwise use the overload taking a noexcept function
31 }
32 inline SignalHandler::Type SignalHandler::GetType () const
33 {
34 return fType_;
35 }
36 inline void SignalHandler::operator() (SignalID i) const
37 {
38 fCall_ (i);
39 }
40
41}
42
44 template <>
45 constexpr EnumNames<Execution::SignalHandler::Type> DefaultNames<Execution::SignalHandler::Type>::k{{{
46 {Execution::SignalHandler::Type::eDirect, L"Direct"},
47 {Execution::SignalHandler::Type::eSafe, L"Safe"},
48 }}};
49}