summaryrefslogtreecommitdiff
path: root/rts/IOManager.h
diff options
context:
space:
mode:
authorDuncan Coutts <duncan@well-typed.com>2020-12-28 23:24:44 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-11-22 02:06:16 -0500
commit8d6aaa49e011ec58f88b65a50a90f64bfd0a1f60 (patch)
tree41612b1a3ab9ee0f3ae9d77611d08d1807818263 /rts/IOManager.h
parent451aeac3b07f171f148995717d0d9a1eefe08f0e (diff)
downloadhaskell-8d6aaa49e011ec58f88b65a50a90f64bfd0a1f60.tar.gz
Introduce CapIOManager as the per-cap I/O mangager state
Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD.
Diffstat (limited to 'rts/IOManager.h')
-rw-r--r--rts/IOManager.h33
1 files changed, 32 insertions, 1 deletions
diff --git a/rts/IOManager.h b/rts/IOManager.h
index f7523149c3..ed7b4dcdcf 100644
--- a/rts/IOManager.h
+++ b/rts/IOManager.h
@@ -21,7 +21,38 @@
#include "BeginPrivate.h"
-/* Init hook: called from hs_init_ghc.
+/* The per-capability data structures belonging to the I/O manager.
+ *
+ * It can be accessed as cap->iomgr.
+ *
+ * The content of the structure is defined conditionally so it is different for
+ * each I/O manager implementation.
+ *
+ * TODO: once the content of this struct is genuinely private, and not shared
+ * with other parts of the RTS, then it can be made opaque, so the content is
+ * known only to the I/O manager and not the rest of the RTS.
+ */
+typedef struct {
+
+#if defined(THREADED_RTS)
+#if !defined(mingw32_HOST_OS)
+ /* Control FD for the MIO manager for this capability */
+ int control_fd;
+#endif
+#endif
+
+} CapIOManager;
+
+
+/* Allocate and initialise the per-capability CapIOManager that lives in each
+ * Capability. It is called from initCapability, via initScheduler,
+ * via hs_init_ghc.
+ */
+void initCapabilityIOManager(CapIOManager **iomgr);
+
+
+/* Init hook: called from hs_init_ghc, very late in the startup after almost
+ * everything else is done.
*/
void initIOManager(void);