1 | /** @file
|
---|
2 | * IPRT - Async I/O manager.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2013 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef ___iprt_aiomgr_h
|
---|
27 | #define ___iprt_aiomgr_h
|
---|
28 |
|
---|
29 | #include <iprt/cdefs.h>
|
---|
30 | #include <iprt/types.h>
|
---|
31 | #include <iprt/sg.h>
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * Completion callback.
|
---|
35 | *
|
---|
36 | * @returns nothing.
|
---|
37 | * @param hAioMgrFile File handle the completed request was for.
|
---|
38 | * @param rcReq Status code of the completed request.
|
---|
39 | * @param pvUser Opaque user data given when the request was initiated.
|
---|
40 | */
|
---|
41 | typedef DECLCALLBACK(void) FNRTAIOMGRREQCOMPLETE(RTAIOMGRFILE hAioMgrFile, int rcReq, void *pvUser);
|
---|
42 | /** Pointer to a completion callback. */
|
---|
43 | typedef FNRTAIOMGRREQCOMPLETE *PFNRTAIOMGRREQCOMPLETE;
|
---|
44 |
|
---|
45 | RT_C_DECLS_BEGIN
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * Create a new async I/O manager.
|
---|
49 | *
|
---|
50 | * @returns IPRT statuse code.
|
---|
51 | * @param phAioMgr Where to store the new async I/O manager handle on success.
|
---|
52 | * @param cReqsMax Maximum number of async I/O requests expected.
|
---|
53 | * Use UINT32_MAX to make it grow dynamically when required.
|
---|
54 | */
|
---|
55 | RTDECL(int) RTAioMgrCreate(PRTAIOMGR phAioMgr, uint32_t cReqsMax);
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * Retain a async I/O manager handle.
|
---|
59 | *
|
---|
60 | * @returns New reference count on success, UINT32_MAX on failure.
|
---|
61 | * @param hAioMgr The async I/O manager to retain.
|
---|
62 | */
|
---|
63 | RTDECL(uint32_t) RTAioMgrRetain(RTAIOMGR hAioMgr);
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * Releases a async I/O manager handle.
|
---|
67 | *
|
---|
68 | * @returns New reference count on success (0 if closed), UINT32_MAX on failure.
|
---|
69 | * @param hAioMgr The async I/O manager to release.
|
---|
70 | */
|
---|
71 | RTDECL(uint32_t) RTAioMgrRelease(RTAIOMGR hAioMgr);
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * Assign a given file handle to the given async I/O manager.
|
---|
75 | *
|
---|
76 | * @returns IPRT status code.
|
---|
77 | * @param hAioMgr Async I/O manager handle.
|
---|
78 | * @param hFile File handle to assign.
|
---|
79 | * @param pfnReqComplete Callback to execute whenever a request for the
|
---|
80 | * file completed.
|
---|
81 | * @param phAioMgrFile Where to store the newly created async I/O manager
|
---|
82 | * handle on success.
|
---|
83 | *
|
---|
84 | * @note This function increases the reference count of the given async I/O manager
|
---|
85 | * by 1.
|
---|
86 | */
|
---|
87 | RTDECL(int) RTAioMgrFileCreate(RTAIOMGR hAioMgr, RTFILE hFile, PFNRTAIOMGRREQCOMPLETE pfnReqComplete,
|
---|
88 | PRTAIOMGRFILE phAioMgrFile);
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * Retain a async I/O manager file handle.
|
---|
92 | *
|
---|
93 | * @returns New reference count on success, UINT32_MAX on failure.
|
---|
94 | * @param hAioMgrFile The file handle to retain.
|
---|
95 | */
|
---|
96 | RTDECL(uint32_t) RTAioMgrFileRetain(RTAIOMGRFILE hAioMgrFile);
|
---|
97 |
|
---|
98 | /**
|
---|
99 | * Releases a async I/O manager file handle.
|
---|
100 | *
|
---|
101 | * @returns New reference count on success (0 if closed), UINT32_MAX on failure.
|
---|
102 | * @param hAioMgrFile The file handle to release.
|
---|
103 | */
|
---|
104 | RTDECL(uint32_t) RTAioMgrFileRelease(RTAIOMGRFILE hAioMgrFile);
|
---|
105 |
|
---|
106 | /**
|
---|
107 | * Initiate a read request from the given file handle.
|
---|
108 | *
|
---|
109 | * @returns IPRT status code.
|
---|
110 | * @param hAioMgrFile The file handle to read from.
|
---|
111 | * @param off Start offset to read from.
|
---|
112 | * @param pSgBuf S/G buffer to read into. The buffer is advanced
|
---|
113 | * by the amount of data to read.
|
---|
114 | * @param cbRead Number of bytes to read.
|
---|
115 | * @param pvUser Opaque user data given in the completion callback.
|
---|
116 | */
|
---|
117 | RTDECL(int) RTAioMgrFileRead(RTAIOMGRFILE hAioMgrFile, RTFOFF off,
|
---|
118 | PRTSGBUF pSgBuf, size_t cbRead, void *pvUser);
|
---|
119 |
|
---|
120 | /**
|
---|
121 | * Initiate a write request to the given file handle.
|
---|
122 | *
|
---|
123 | * @returns IPRT status code.
|
---|
124 | * @param hAioMgrFile The file handle to write to.
|
---|
125 | * @param off Start offset to write to.
|
---|
126 | * @param pSgBuf S/G buffer to read from. The buffer is advanced
|
---|
127 | * by the amount of data to write.
|
---|
128 | * @param cbWrite Number of bytes to write.
|
---|
129 | * @param pvUser Opaque user data given in the completion callback.
|
---|
130 | */
|
---|
131 | RTDECL(int) RTAioMgrFileWrite(RTAIOMGRFILE hAioMgrFile, RTFOFF off,
|
---|
132 | PRTSGBUF pSgBuf, size_t cbWrite, void *pvUser);
|
---|
133 |
|
---|
134 | /**
|
---|
135 | * Initiates a flush request for the given file handle.
|
---|
136 | *
|
---|
137 | * @returns IPRT statuse code.
|
---|
138 | * @param hAioMgrFile The file handle to write to.
|
---|
139 | * @param pvUser Opaque user data given in the completion callback.
|
---|
140 | */
|
---|
141 | RTDECL(int) RTAioMgrFileFlush(RTAIOMGRFILE hAioMgrFile, void *pvUser);
|
---|
142 |
|
---|
143 | RT_C_DECLS_END
|
---|
144 |
|
---|
145 | #endif
|
---|
146 |
|
---|