etc/comp_channel: add completion channel abstraction for scalability
[mirror/winof/.git] / inc / user / comp_channel.h
1 /*\r
2  * Copyright (c) 2009 Intel Corp., Inc.  All rights reserved.\r
3  *\r
4  * This software is available to you under the OpenIB.org BSD license\r
5  * below:\r
6  *\r
7  *     Redistribution and use in source and binary forms, with or\r
8  *     without modification, are permitted provided that the following\r
9  *     conditions are met:\r
10  *\r
11  *      - Redistributions of source code must retain the above\r
12  *        copyright notice, this list of conditions and the following\r
13  *        disclaimer.\r
14  *\r
15  *      - Redistributions in binary form must reproduce the above\r
16  *        copyright notice, this list of conditions and the following\r
17  *        disclaimer in the documentation and/or other materials\r
18  *        provided with the distribution.\r
19  *\r
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV\r
23  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
24  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
25  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
26  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
27  * SOFTWARE.\r
28  */\r
29 \r
30 #pragma once\r
31 \r
32 #ifndef COMP_CHANNEL_H\r
33 #define COMP_CHANNEL_H\r
34 \r
35 #include <windows.h>\r
36 \r
37 #ifdef __cplusplus\r
38 extern "C" {\r
39 #endif\r
40 \r
41 typedef struct _COMP_ENTRY\r
42 {\r
43         struct _COMP_ENTRY              *Next;\r
44         OVERLAPPED                              Overlap;\r
45         struct _COMP_CHANNEL    *Channel;\r
46 \r
47 }       COMP_ENTRY;\r
48 \r
49 typedef struct _COMP_CHANNEL\r
50 {\r
51         struct _COMP_MANAGER    *Manager;\r
52         COMP_ENTRY                              *Head;\r
53         COMP_ENTRY                              **TailPtr;\r
54         CRITICAL_SECTION                Lock;\r
55         DWORD                                   Milliseconds;\r
56 \r
57 }       COMP_CHANNEL;\r
58 \r
59 typedef struct _COMP_MANAGER\r
60 {\r
61         HANDLE                                  CompQueue;\r
62         HANDLE                                  Event;\r
63         LONG volatile                   Lock;\r
64 \r
65 }       COMP_MANAGER;\r
66 \r
67 DWORD           CompManagerOpen(COMP_MANAGER *pMgr);\r
68 void            CompManagerClose(COMP_MANAGER *pMgr);\r
69 DWORD           CompManagerMonitor(COMP_MANAGER *pMgr, HANDLE hFile, ULONG_PTR Key);\r
70 DWORD           CompManagerPoll(COMP_MANAGER *pMgr, DWORD Milliseconds,\r
71                                                         COMP_CHANNEL **ppChannel);\r
72 \r
73 void            CompChannelInit(COMP_MANAGER *pMgr, COMP_CHANNEL *pChannel,\r
74                                                         DWORD Milliseconds);\r
75 void            CompChannelCleanup(COMP_CHANNEL *pChannel);\r
76 DWORD           CompChannelPoll(COMP_CHANNEL *pChannel, COMP_ENTRY **ppEntry);\r
77 void            CompChannelRemoveEntry(COMP_CHANNEL *pChannel, COMP_ENTRY *pEntry);\r
78 \r
79 void            CompEntryInit(COMP_CHANNEL *pChannel, COMP_ENTRY *pEntry);\r
80 DWORD           CompEntryPost(COMP_ENTRY *pEntry);\r
81 \r
82 #ifdef __cplusplus\r
83 }\r
84 #endif\r
85 \r
86 #endif /* COMP_CHANNEL_H */\r