librdmacm: fix event reporting when destroying listen
[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 #include <dlist.h>\r
37 \r
38 #ifdef __cplusplus\r
39 extern "C" {\r
40 #endif\r
41 \r
42 typedef struct _COMP_ENTRY\r
43 {\r
44         struct _COMP_ENTRY              *Next;\r
45         DLIST_ENTRY                             MgrEntry;\r
46         OVERLAPPED                              Overlap;\r
47         struct _COMP_CHANNEL    *Channel;\r
48         LONG volatile                   Busy;\r
49 \r
50 }       COMP_ENTRY;\r
51 \r
52 typedef struct _COMP_CHANNEL\r
53 {\r
54         struct _COMP_MANAGER    *Manager;\r
55         COMP_ENTRY                              *Head;\r
56         COMP_ENTRY                              **TailPtr;\r
57         COMP_ENTRY                              Entry;\r
58         HANDLE                                  Event;\r
59         CRITICAL_SECTION                Lock;\r
60         DWORD                                   Milliseconds;\r
61 \r
62 }       COMP_CHANNEL;\r
63 \r
64 typedef struct _COMP_MANAGER\r
65 {\r
66         HANDLE                                  CompQueue;\r
67         DLIST_ENTRY                             DoneList;\r
68         COMP_ENTRY                              Entry;\r
69         HANDLE                                  Thread;\r
70         BOOL                                    Run;\r
71         HANDLE                                  Event;\r
72         LONG volatile                   Busy;\r
73         CRITICAL_SECTION                Lock;\r
74 \r
75 }       COMP_MANAGER;\r
76 \r
77 DWORD           CompManagerOpen(COMP_MANAGER *pMgr);\r
78 void            CompManagerClose(COMP_MANAGER *pMgr);\r
79 DWORD           CompManagerMonitor(COMP_MANAGER *pMgr, HANDLE hFile, ULONG_PTR Key);\r
80 DWORD           CompManagerPoll(COMP_MANAGER *pMgr, DWORD Milliseconds,\r
81                                                         COMP_CHANNEL **ppChannel);\r
82 void            CompManagerCancel(COMP_MANAGER *pMgr);\r
83 \r
84 DWORD           CompChannelInit(COMP_MANAGER *pMgr, COMP_CHANNEL *pChannel,\r
85                                                         DWORD Milliseconds);\r
86 void            CompChannelCleanup(COMP_CHANNEL *pChannel);\r
87 DWORD           CompChannelPoll(COMP_CHANNEL *pChannel, COMP_ENTRY **ppEntry);\r
88 void            CompChannelCancel(COMP_CHANNEL *pChannel);\r
89 \r
90 void            CompEntryInit(COMP_CHANNEL *pChannel, COMP_ENTRY *pEntry);\r
91 DWORD           CompEntryPost(COMP_ENTRY *pEntry);\r
92 COMP_ENTRY      *CompEntryCancel(COMP_ENTRY *pEntry);\r
93 \r
94 #ifdef __cplusplus\r
95 }\r
96 #endif\r
97 \r
98 #endif /* COMP_CHANNEL_H */\r