source: trunk/src/kernel32/overlappedio.h@ 7552

Last change on this file since 7552 was 7552, checked in by sandervl, 24 years ago

overlapped io updates

File size: 3.4 KB
Line 
1/* $Id: overlappedio.h,v 1.3 2001-12-05 19:24:37 sandervl Exp $ */
2
3/*
4 * Win32 overlapped IO class
5 *
6 * Copyright 2001 Sander van Leeuwen <sandervl@xs4all.nl>
7 *
8 * Project Odin Software License can be found in LICENSE.TXT
9 *
10 */
11
12#ifndef __OVERLAPPEDIO_H__
13#define __OVERLAPPEDIO_H__
14
15#define NR_ASYNC_OPERATIONS 3
16#define ASYNC_INDEX_READ 0
17#define ASYNC_INDEX_WRITE 1
18#define ASYNC_INDEX_POLL 2
19
20#define ASYNCIO_READ 1
21#define ASYNCIO_WRITE 2
22#define ASYNCIO_READWRITE 4
23#define ASYNCIO_POLL 8
24
25//forward decl
26class OverlappedIOHandler;
27
28typedef struct {
29 DWORD dwOperation;
30 OverlappedIOHandler *lpOverlappedObj;
31} OVERLAPPED_THREAD_PARAM, *LPOVERLAPPED_THREAD_PARAM;
32
33typedef struct tagOVERLAPPED_ODIN{
34 DWORD dwAsyncType;
35 HANDLE hOS2Handle;
36 LPCVOID lpBuffer;
37 ULONG nNumberOfBytes;
38 LPOVERLAPPED lpOverlapped;
39 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine;
40 DWORD *lpResult;
41 DWORD dwUserData;
42 tagOVERLAPPED_ODIN *next;
43} ASYNCIOREQUEST, *LPASYNCIOREQUEST;
44
45typedef DWORD (* SYSTEM LPOVERLAPPED_HANDLER)(LPASYNCIOREQUEST lpRequest);
46
47enum OverlappedIOError {
48 InvalidParameter, OutOfMemory, EventCreationFailed, ThreadCreationFailed
49};
50
51class OverlappedIOHandler
52{
53public:
54 OverlappedIOHandler(LPOVERLAPPED_HANDLER lpReadHandler,
55 LPOVERLAPPED_HANDLER lpWriteHandler,
56 LPOVERLAPPED_HANDLER lpPollHandler = NULL);
57 ~OverlappedIOHandler();
58
59 BOOL WriteFile(HANDLE hOS2Handle,
60 LPCVOID lpBuffer,
61 DWORD nNumberOfBytesToWrite,
62 LPDWORD lpNumberOfBytesWritten,
63 LPOVERLAPPED lpOverlapped,
64 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
65 DWORD dwUserData);
66
67 BOOL ReadFile(HANDLE hOS2Handle,
68 LPCVOID lpBuffer,
69 DWORD nNumberOfBytesToRead,
70 LPDWORD lpNumberOfBytesRead,
71 LPOVERLAPPED lpOverlapped,
72 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
73 DWORD dwUserData);
74
75 BOOL CancelIo(HANDLE hOS2Handle);
76
77 BOOL GetOverlappedResult(HANDLE hOS2Handle,
78 LPOVERLAPPED lpoOverlapped,
79 LPDWORD lpcbTransfer,
80 DWORD dwTimeout);
81
82protected:
83
84private:
85
86 DWORD threadHandler(DWORD fEvent);
87
88 HANDLE hThreadPoll;
89 HANDLE hThreadRead;
90 HANDLE hThreadWrite;
91 HANDLE hEventExit;
92 HANDLE hEventPoll;
93 HANDLE hEventRead;
94 HANDLE hEventWrite;
95
96 LPOVERLAPPED_HANDLER lpReadHandler;
97 LPOVERLAPPED_HANDLER lpWriteHandler;
98 LPOVERLAPPED_HANDLER lpPollHandler;
99
100 CRITICAL_SECTION critsect;
101
102 DWORD dwAsyncType;
103 //[ASYNC_INDEX_READ] list of pending read (+ write if half-duplex mode) operations
104 //[ASYNC_INDEX_WRITE] list of pending write (full-duplex mode) operations
105 //[ASYNC_INDEX_POLL] list of pending poll operations
106 LPASYNCIOREQUEST pending[NR_ASYNC_OPERATIONS];
107
108 friend DWORD CALLBACK OverlappedIOThread(LPVOID lpThreadParam);
109};
110
111
112#endif // __OVERLAPPEDIO_H__
Note: See TracBrowser for help on using the repository browser.