Changeset 46246 in vbox
- Timestamp:
- May 23, 2013 7:15:44 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 85975
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/include/iprt/aiomgr.h ¶
r45723 r46246 81 81 * @param phAioMgrFile Where to store the newly created async I/O manager 82 82 * handle on success. 83 * @param pvUser Opaque user data for this file handle. 83 84 * 84 85 * @note This function increases the reference count of the given async I/O manager … … 86 87 */ 87 88 RTDECL(int) RTAioMgrFileCreate(RTAIOMGR hAioMgr, RTFILE hFile, PFNRTAIOMGRREQCOMPLETE pfnReqComplete, 88 PRTAIOMGRFILE phAioMgrFile);89 void *pvUser, PRTAIOMGRFILE phAioMgrFile); 89 90 90 91 /** … … 103 104 */ 104 105 RTDECL(uint32_t) RTAioMgrFileRelease(RTAIOMGRFILE hAioMgrFile); 106 107 /** 108 * Return opaque user data passed on creation. 109 * 110 * @returns Opaque user data or NULL if the handle is invalid. 111 * @param hAioMgrFile The file handle. 112 */ 113 RTDECL(void *) RTAioMgrFileGetUser(RTAIOMGRFILE hAioMgrFile); 105 114 106 115 /** -
TabularUnified trunk/src/VBox/Runtime/common/misc/aiomgr.cpp ¶
r46233 r46246 123 123 /** Flags. */ 124 124 uint32_t fFlags; 125 /** Opaque user data passed on creation. */ 126 void *pvUser; 125 127 /** File handle. */ 126 128 RTFILE hFile; … … 476 478 477 479 pReqsHead = (PRTAIOMGRREQ)pReqsHead->WorkItem.pNext; 478 pReq sHead->WorkItem.pNext = NULL;480 pReqCur->WorkItem.pNext = NULL; 479 481 RTListAppend(&pFile->AioMgr.ListWaitingReqs, &pReqCur->NodeWaitingList); 480 482 } … … 1003 1005 pThis->hMemCacheReqs = NIL_RTMEMCACHE; 1004 1006 pThis->u32Magic = ~RTAIOMGR_MAGIC; 1007 RTCritSectDelete(&pThis->CritSectBlockingEvent); 1008 RTSemEventDestroy(pThis->hEventSemBlock); 1005 1009 RTMemFree(pThis); 1006 1010 } … … 1025 1029 { 1026 1030 pThis->u32Magic = ~RTAIOMGRFILE_MAGIC; 1031 rtAioMgrCloseFile(pThis->pAioMgr, pThis); 1027 1032 RTAioMgrRelease(pThis->pAioMgr); 1028 1033 RTMemFree(pThis); … … 1122 1127 pThis->u32Magic = RTAIOMGR_MAGIC; 1123 1128 pThis->cRefs = 1; 1129 pThis->enmBlockingEvent = RTAIOMGREVENT_NO_EVENT; 1124 1130 RTListInit(&pThis->ListFiles); 1125 rc = RTMemCacheCreate(&pThis->hMemCacheReqs, sizeof(RTAIOMGRREQ), 1126 0, UINT32_MAX, rtAioMgrReqCtor, rtAioMgrReqDtor, NULL, 0); 1131 rc = RTCritSectInit(&pThis->CritSectBlockingEvent); 1127 1132 if (RT_SUCCESS(rc)) 1128 1133 { 1129 rc = RTFileAioCtxCreate(&pThis->hAioCtx, cReqsMax == UINT32_MAX 1130 ? RTFILEAIO_UNLIMITED_REQS 1131 : cReqsMax, 1132 RTFILEAIOCTX_FLAGS_WAIT_WITHOUT_PENDING_REQUESTS); 1134 rc = RTSemEventCreate(&pThis->hEventSemBlock); 1133 1135 if (RT_SUCCESS(rc)) 1134 1136 { 1135 rc = RTThreadCreateF(&pThis->hThread, rtAioMgrWorker, pThis, 0, RTTHREADTYPE_IO, 1136 RTTHREADFLAGS_WAITABLE, "AioMgr-%p", pThis); 1137 rc = RTMemCacheCreate(&pThis->hMemCacheReqs, sizeof(RTAIOMGRREQ), 1138 0, UINT32_MAX, rtAioMgrReqCtor, rtAioMgrReqDtor, NULL, 0); 1139 if (RT_SUCCESS(rc)) 1140 { 1141 rc = RTFileAioCtxCreate(&pThis->hAioCtx, cReqsMax == UINT32_MAX 1142 ? RTFILEAIO_UNLIMITED_REQS 1143 : cReqsMax, 1144 RTFILEAIOCTX_FLAGS_WAIT_WITHOUT_PENDING_REQUESTS); 1145 if (RT_SUCCESS(rc)) 1146 { 1147 rc = RTThreadCreateF(&pThis->hThread, rtAioMgrWorker, pThis, 0, RTTHREADTYPE_IO, 1148 RTTHREADFLAGS_WAITABLE, "AioMgr-%u", cReqsMax); 1149 if (RT_FAILURE(rc)) 1150 { 1151 rc = RTFileAioCtxDestroy(pThis->hAioCtx); 1152 AssertRC(rc); 1153 } 1154 } 1155 1156 if (RT_FAILURE(rc)) 1157 RTMemCacheDestroy(pThis->hMemCacheReqs); 1158 } 1159 1137 1160 if (RT_FAILURE(rc)) 1138 { 1139 rc = RTFileAioCtxDestroy(pThis->hAioCtx); 1140 AssertRC(rc); 1141 } 1161 RTSemEventDestroy(pThis->hEventSemBlock); 1142 1162 } 1143 1163 1144 1164 if (RT_FAILURE(rc)) 1145 RT MemCacheDestroy(pThis->hMemCacheReqs);1165 RTCritSectDelete(&pThis->CritSectBlockingEvent); 1146 1166 } 1147 1167 … … 1186 1206 1187 1207 RTDECL(int) RTAioMgrFileCreate(RTAIOMGR hAioMgr, RTFILE hFile, PFNRTAIOMGRREQCOMPLETE pfnReqComplete, 1188 PRTAIOMGRFILE phAioMgrFile)1208 void *pvUser, PRTAIOMGRFILE phAioMgrFile) 1189 1209 { 1190 1210 int rc = VINF_SUCCESS; … … 1203 1223 pThis->hFile = hFile; 1204 1224 pThis->pAioMgr = hAioMgr; 1225 pThis->pvUser = pvUser; 1205 1226 pThis->pfnReqCompleted = pfnReqComplete; 1206 1227 RTQueueAtomicInit(&pThis->QueueReqs); 1228 RTListInit(&pThis->AioMgr.ListWaitingReqs); 1207 1229 RTAioMgrRetain(hAioMgr); 1208 1230 rc = RTFileAioCtxAssociateWithFile(pThis->pAioMgr->hAioCtx, hFile); 1209 1231 if (RT_FAILURE(rc)) 1210 1232 rtAioMgrFileDestroy(pThis); 1233 else 1234 rtAioMgrAddFile(pThis->pAioMgr, pThis); 1211 1235 } 1212 1236 else … … 1246 1270 } 1247 1271 1272 RTDECL(void *) RTAioMgrFileGetUser(RTAIOMGRFILE hAioMgrFile) 1273 { 1274 PRTAIOMGRFILEINT pThis = hAioMgrFile; 1275 1276 AssertPtrReturn(pThis, NULL); 1277 return pThis->pvUser; 1278 } 1279 1248 1280 RTDECL(int) RTAioMgrFileRead(RTAIOMGRFILE hAioMgrFile, RTFOFF off, 1249 1281 PRTSGBUF pSgBuf, size_t cbRead, void *pvUser)
Note:
See TracChangeset
for help on using the changeset viewer.