summaryrefslogtreecommitdiff
path: root/rts/IOManager.c
diff options
context:
space:
mode:
authorDuncan Coutts <duncan@well-typed.com>2020-12-28 22:15:06 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-01-25 05:11:14 -0500
commit4ad726fc1a5d062e2df2910d7f39ab81428dddfc (patch)
tree93adbaf8d20c8baa142c8cbb79d4c2c167b64925 /rts/IOManager.c
parente93384e82fb4de5a5ee96949b7c1108bce16a875 (diff)
downloadhaskell-4ad726fc1a5d062e2df2910d7f39ab81428dddfc.tar.gz
Move hooks for I/O manager startup / shutdown into IOManager.{c,h}
Diffstat (limited to 'rts/IOManager.c')
-rw-r--r--rts/IOManager.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/rts/IOManager.c b/rts/IOManager.c
index 03811f1daa..eaa1fe8cb6 100644
--- a/rts/IOManager.c
+++ b/rts/IOManager.c
@@ -20,6 +20,73 @@
#include "IOManager.h" // RTS internal
#include "Capability.h"
+#if defined(mingw32_HOST_OS) && !defined(THREADED_RTS)
+#include "win32/AsyncMIO.h"
+#include "win32/AsyncWinIO.h"
+#endif
+
+
+/* Called in the RTS initialisation
+ */
+void
+initIOManager(void)
+{
+
+#if defined(THREADED_RTS)
+ /* Posix implementation in posix/Signals.c
+ * Win32 implementation in win32/ThrIOManager.c
+ */
+ ioManagerStart();
+
+#elif defined(mingw32_HOST_OS)
+ /* Non-threaded Win32 implementation, either the WinIO IOCP implementation,
+ * or the classic implementation. */
+ if (is_io_mng_native_p()) {
+ startupAsyncWinIO();
+ } else {
+ startupAsyncIO();
+ }
+
+#else
+ /* The other implementation is the non-threaded Posix select() one.
+ * It does not need any initialisation.
+ */
+#endif
+
+}
+
+
+/* Called in the RTS shutdown before the scheduler exits
+ */
+void
+stopIOManager(void)
+{
+
+#if defined(THREADED_RTS)
+ /* Posix implementation in posix/Signals.c
+ * Win32 implementation in win32/ThrIOManager.c
+ */
+ ioManagerDie();
+#endif
+
+}
+
+
+/* Called in the RTS shutdown after the scheduler exits
+ */
+void
+exitIOManager(bool wait_threads USED_IF_NOT_THREADS_AND_MINGW32)
+{
+
+#if !defined(THREADED_RTS) && defined(mingw32_HOST_OS)
+ if (is_io_mng_native_p()) {
+ shutdownAsyncWinIO(wait_threads);
+ } else {
+ shutdownAsyncIO(wait_threads);
+ }
+#endif
+
+}
/* Declared in rts/IOInterface.h. Used only by the MIO threaded I/O manager on
* Unix platforms.