Stroika Library 3.0d25
 
Loading...
Searching...
No Matches
SignalHandlers.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2026. 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 inline strong_ordering SignalHandler::operator<=> (const SignalHandler& rhs) const
41 {
42 if (strong_ordering cmp = fType_ <=> rhs.fType_; cmp != 0) {
43 return cmp;
44 }
45 return fIdentity_ <=> rhs.fIdentity_;
46 }
47 inline bool SignalHandler::operator== (const SignalHandler& rhs) const
48 {
49 return fType_ == rhs.fType_ and fIdentity_ == rhs.fIdentity_;
50 }
51
52}
53
55 template <>
56 constexpr EnumNames<Execution::SignalHandler::Type> DefaultNames<Execution::SignalHandler::Type>::k{{{
57 {Execution::SignalHandler::Type::eDirect, L"Direct"},
58 {Execution::SignalHandler::Type::eSafe, L"Safe"},
59 }}};
60}