summaryrefslogtreecommitdiff
path: root/cpp/include
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2017-04-22 18:02:53 -0400
committerBernard Normier <bernard@zeroc.com>2017-04-22 18:02:53 -0400
commitbd960c70612403251494030dffdaa86cf46a6384 (patch)
tree3618f57a3d89c3eab97b0d42f7730e62143408dd /cpp/include
parentFix (ICE-7780) - Glacier2::Application cleanup (diff)
downloadice-bd960c70612403251494030dffdaa86cf46a6384.tar.bz2
ice-bd960c70612403251494030dffdaa86cf46a6384.tar.xz
ice-bd960c70612403251494030dffdaa86cf46a6384.zip
Improved C++11 version of CtrlCHandler
Diffstat (limited to 'cpp/include')
-rw-r--r--cpp/include/Ice/Application.h3
-rw-r--r--cpp/include/IceUtil/CtrlCHandler.h26
-rw-r--r--cpp/include/IceUtil/IceUtil.h4
3 files changed, 20 insertions, 13 deletions
diff --git a/cpp/include/Ice/Application.h b/cpp/include/Ice/Application.h
index 57aeea57821..034b3cdbde4 100644
--- a/cpp/include/Ice/Application.h
+++ b/cpp/include/Ice/Application.h
@@ -13,10 +13,13 @@
#include <Ice/Initialize.h>
#include <IceUtil/Mutex.h>
#include <IceUtil/Cond.h>
+#include <IceUtil/CtrlCHandler.h>
namespace Ice
{
+using IceUtil::CtrlCHandler;
+
#ifdef ICE_CPP11_MAPPING
enum class SignalPolicy : unsigned char
#else
diff --git a/cpp/include/IceUtil/CtrlCHandler.h b/cpp/include/IceUtil/CtrlCHandler.h
index d203804b898..a27554a8852 100644
--- a/cpp/include/IceUtil/CtrlCHandler.h
+++ b/cpp/include/IceUtil/CtrlCHandler.h
@@ -17,22 +17,22 @@ namespace IceUtil
{
// The CtrlCHandler provides a portable way to handle CTRL+C and
-// CTRL+C like signals
-// On Unix/POSIX, the CtrlCHandler handles SIGHUP, SIGINT and SIGTERM.
+// CTRL+C like signals
+// On Unix/POSIX, the CtrlCHandler handles SIGHUP, SIGINT and SIGTERM.
// On Windows, it is essentially a wrapper for SetConsoleCtrlHandler().
-//
-// In a process, only one CtrlCHandler can exist at a given time:
+//
+// In a process, only one CtrlCHandler can exist at a given time:
// the CtrlCHandler constructor raises CtrlCHandlerException if
// you attempt to create a second CtrlCHandler.
// On Unix/POSIX, it is essential to create the CtrlCHandler before
// creating any thread, as the CtrlCHandler constructor masks (blocks)
-// SIGHUP, SIGINT and SIGTERM; by default, threads created later will
+// SIGHUP, SIGINT and SIGTERM; by default, threads created later will
// inherit this signal mask.
//
-// When a CTRL+C or CTRL+C like signal is sent to the process, the
-// user-registered callback is called in a separate thread; it is
+// When a CTRL+C or CTRL+C like signal is sent to the process, the
+// user-registered callback is called in a separate thread; it is
// given the signal number. The callback must not raise exceptions.
-// On Unix/POSIX, the callback is NOT a signal handler and can call
+// On Unix/POSIX, the callback is NOT a signal handler and can call
// functions that are not async-signal safe.
//
// The CtrCHandler destructor "unregisters" the callback. However
@@ -42,13 +42,17 @@ namespace IceUtil
// TODO: Maybe the behavior on Windows should be the same? Now we
// just restore the default behavior (TerminateProcess).
+#ifdef ICE_CPP11_MAPPING
+using CtrlCHandlerCallback = std::function<void(int)>;
+#else
typedef void (*CtrlCHandlerCallback)(int);
+#endif
class ICE_API CtrlCHandler
{
public:
- CtrlCHandler(CtrlCHandlerCallback = 0);
+ CtrlCHandler(CtrlCHandlerCallback = ICE_NULLPTR);
~CtrlCHandler();
void setCallback(CtrlCHandlerCallback);
@@ -56,9 +60,9 @@ public:
};
class ICE_API CtrlCHandlerException : public ExceptionHelper<CtrlCHandlerException>
-{
+{
public:
-
+
CtrlCHandlerException(const char*, int);
virtual std::string ice_id() const;
diff --git a/cpp/include/IceUtil/IceUtil.h b/cpp/include/IceUtil/IceUtil.h
index 1d29150ef83..82dcaa07db8 100644
--- a/cpp/include/IceUtil/IceUtil.h
+++ b/cpp/include/IceUtil/IceUtil.h
@@ -13,14 +13,14 @@
#include <IceUtil/PushDisableWarnings.h>
//
-// This file must include *all* other headers of IceUtil, except
+// This file must include *all* headers of IceUtil, except
// for DisableWarnings.h and headers with only IceUtilInternal symbols
//
#include <IceUtil/Config.h>
#include <IceUtil/Cond.h>
#include <IceUtil/ConsoleUtil.h>
-#if !defined(__APPLE__) && !defined(ICE_OS_UWP)
+#if !defined(ICE_OS_UWP) && (!defined(__APPLE__) || TARGET_OS_IPHONE == 0)
# include <IceUtil/CtrlCHandler.h>
#endif
#include <IceUtil/Exception.h>