From 4ee4169619372074140c18a3162fdd910f2d542b Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 11 Nov 2019 09:24:56 +0000 Subject: [PATCH] added QSE::App::acceptSignals(), QSE::App::discardSignals(), QSE::App::neglectSignals() --- qse/include/qse/si/App.hpp | 5 +++++ qse/lib/si/App.cpp | 45 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/qse/include/qse/si/App.hpp b/qse/include/qse/si/App.hpp index 4272a8cf..e11536c0 100644 --- a/qse/include/qse/si/App.hpp +++ b/qse/include/qse/si/App.hpp @@ -137,6 +137,11 @@ public: return this->setSignalSubscription(sig, SIGNAL_NEGLECTED, ignore_if_unhandled); } + int acceptSignals (const SignalSet& signals); + int discardSignals (const SignalSet& signals); + int neglectSignals (const SignalSet& signals, bool ignore_if_unhandled = false); + + typedef void (*SignalHandler) (int sig); static qse_size_t _sighrs[2][QSE_NSIGS]; diff --git a/qse/lib/si/App.cpp b/qse/lib/si/App.cpp index 3389c4fc..8a0dc4b6 100644 --- a/qse/lib/si/App.cpp +++ b/qse/lib/si/App.cpp @@ -457,6 +457,51 @@ int App::set_signal_subscription_no_mutex (int sig, SignalState reqstate, bool i return reqstate; } +int App::acceptSignals (const SignalSet& signals) +{ + int n = 0; + + for (int i = 0; i < QSE_NSIGS; i++) + { + if (signals.isSet(i)) + { + if (this->setSignalSubscription(i, SIGNAL_ACCEPTED) <= -1) n = -1; + } + } + + return n; +} + +int App::discardSignals (const SignalSet& signals) +{ + int n = 0; + + for (int i = 0; i < QSE_NSIGS; i++) + { + if (signals.isSet(i)) + { + if (this->setSignalSubscription(i, SIGNAL_DISCARDED) <= -1) n = -1; + } + } + + return n; +} + +int App::neglectSignals (const SignalSet& signals, bool ignore_if_unhandled) +{ + int n = 0; + + for (int i = 0; i < QSE_NSIGS; i++) + { + if (signals.isSet(i)) + { + if (this->setSignalSubscription(i, SIGNAL_NEGLECTED, ignore_if_unhandled) <= -1) n = -1; + } + } + + return n; +} + int App::guardProcess (const SignalSet& signals, qse_mtime_t guard_pause_ms, const qse_mchar_t* proc_name) { SignalState old_ss[QSE_NSIGS];