diff options
author | Simon Marlow <simonmar@microsoft.com> | 2006-04-07 02:05:11 +0000 |
---|---|---|
committer | Simon Marlow <simonmar@microsoft.com> | 2006-04-07 02:05:11 +0000 |
commit | 0065d5ab628975892cea1ec7303f968c3338cbe1 (patch) | |
tree | 8e2afe0ab48ee33cf95009809d67c9649573ef92 /rts/win32/IOManager.h | |
parent | 28a464a75e14cece5db40f2765a29348273ff2d2 (diff) | |
download | haskell-0065d5ab628975892cea1ec7303f968c3338cbe1.tar.gz |
Reorganisation of the source tree
Most of the other users of the fptools build system have migrated to
Cabal, and with the move to darcs we can now flatten the source tree
without losing history, so here goes.
The main change is that the ghc/ subdir is gone, and most of what it
contained is now at the top level. The build system now makes no
pretense at being multi-project, it is just the GHC build system.
No doubt this will break many things, and there will be a period of
instability while we fix the dependencies. A straightforward build
should work, but I haven't yet fixed binary/source distributions.
Changes to the Building Guide will follow, too.
Diffstat (limited to 'rts/win32/IOManager.h')
-rw-r--r-- | rts/win32/IOManager.h | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/rts/win32/IOManager.h b/rts/win32/IOManager.h new file mode 100644 index 0000000000..4893e2387c --- /dev/null +++ b/rts/win32/IOManager.h @@ -0,0 +1,110 @@ +/* IOManager.h + * + * Non-blocking / asynchronous I/O for Win32. + * + * (c) sof, 2002-2003 + */ +#ifndef __IOMANAGER_H__ +#define __IOMANAGER_H__ +/* On the yucky side..suppress -Wmissing-declarations warnings when + * including <windows.h> + */ +extern void* GetCurrentFiber ( void ); +extern void* GetFiberData ( void ); +#include <windows.h> + +/* + The IOManager subsystem provides a non-blocking view + of I/O operations. It lets one (or more) OS thread(s) + issue multiple I/O requests, which the IOManager then + handles independently of/concurrent to the thread(s) + that issued the request. Upon completion, the issuing + thread can inspect the result of the I/O operation & + take appropriate action. + + The IOManager is intended used with the GHC RTS to + implement non-blocking I/O in Concurrent Haskell. + */ + +/* + * Our WorkQueue holds WorkItems, encoding IO and + * delay requests. + * + */ +typedef void (*CompletionProc)(unsigned int requestID, + int fd, + int len, + void* buf, + int errCode); + +/* + * Asynchronous procedure calls executed by a worker thread + * take a generic state argument pointer and return an int by + * default. + */ +typedef int (*DoProcProc)(void *param); + +typedef union workData { + struct { + int fd; + int len; + char *buf; + } ioData; + struct { + int msecs; + } delayData; + struct { + DoProcProc proc; + void* param; + } procData; +} WorkData; + +typedef struct WorkItem { + unsigned int workKind; + WorkData workData; + unsigned int requestID; + CompletionProc onCompletion; + unsigned int abandonOp; + struct WorkItem *link; +} WorkItem; + +extern CompletionProc onComplete; + +/* the kind of operations supported; you could easily imagine + * that instead of passing a tag describing the work to be performed, + * a function pointer is passed instead. Maybe later. + */ +#define WORKER_READ 1 +#define WORKER_WRITE 2 +#define WORKER_DELAY 4 +#define WORKER_FOR_SOCKET 8 +#define WORKER_DO_PROC 16 + +/* + * Starting up and shutting down. + */ +extern BOOL StartIOManager ( void ); +extern void ShutdownIOManager ( void ); + +/* + * Adding I/O and delay requests. With each request a + * completion routine is supplied, which the worker thread + * will invoke upon completion. + */ +extern int AddDelayRequest ( unsigned int msecs, + CompletionProc onCompletion); + +extern int AddIORequest ( int fd, + BOOL forWriting, + BOOL isSocket, + int len, + char* buffer, + CompletionProc onCompletion); + +extern int AddProcRequest ( void* proc, + void* data, + CompletionProc onCompletion); + +extern void abandonWorkRequest ( int reqID ); + +#endif /* __IOMANAGER_H__ */ |