3 * Non-blocking / asynchronous I/O for Win32.
7 #ifndef __IOMANAGER_H__
8 #define __IOMANAGER_H__
9 /* On the yucky side..suppress -Wmissing-declarations warnings when
10 * including <windows.h>
12 extern void* GetCurrentFiber ( void );
13 extern void* GetFiberData ( void );
17 The IOManager subsystem provides a non-blocking view
18 of I/O operations. It lets one (or more) OS thread(s)
19 issue multiple I/O requests, which the IOManager then
20 handles independently of/concurrent to the thread(s)
21 that issued the request. Upon completion, the issuing
22 thread can inspect the result of the I/O operation &
23 take appropriate action.
25 The IOManager is intended used with the GHC RTS to
26 implement non-blocking I/O in Concurrent Haskell.
30 * Our WorkQueue holds WorkItems, encoding IO and
34 typedef void (*CompletionProc)(unsigned int requestID,
40 typedef void (*DoProcProc)(void *param);
42 typedef union workData {
57 typedef struct WorkItem {
58 unsigned int workKind;
60 unsigned int requestID;
61 CompletionProc onCompletion;
64 extern CompletionProc onComplete;
66 /* the kind of operations supported; you could easily imagine
67 * that instead of passing a tag describing the work to be performed,
68 * a function pointer is passed instead. Maybe later.
71 #define WORKER_WRITE 2
72 #define WORKER_DELAY 4
73 #define WORKER_FOR_SOCKET 8
74 #define WORKER_DO_PROC 16
77 * Starting up and shutting down.
79 extern BOOL StartIOManager ( void );
80 extern void ShutdownIOManager ( void );
83 * Adding I/O and delay requests. With each request a
84 * completion routine is supplied, which the worker thread
85 * will invoke upon completion.
87 extern int AddDelayRequest ( unsigned int msecs,
88 CompletionProc onCompletion);
90 extern int AddIORequest ( int fd,
95 CompletionProc onCompletion);
97 extern int AddProcRequest ( void* proc,
99 CompletionProc onCompletion);
101 #endif /* __IOMANAGER_H__ */