From 4ad726fc1a5d062e2df2910d7f39ab81428dddfc Mon Sep 17 00:00:00 2001 From: Duncan Coutts Date: Mon, 28 Dec 2020 22:15:06 +0000 Subject: Move hooks for I/O manager startup / shutdown into IOManager.{c,h} --- rts/IOManager.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'rts/IOManager.c') 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. -- cgit v1.2.1