VirtualBox

source: vbox/trunk/include/VBox/pdmasynccompletion.h@ 7944

Last change on this file since 7944 was 7823, checked in by vboxsync, 17 years ago

eol-style and keywords again

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 20.4 KB
Line 
1/* $Id: pdmasynccompletion.h 7823 2008-04-09 09:32:17Z vboxsync $ */
2/** @file
3 * PDM - Pluggable Device Manager, Async I/O Completion.
4 */
5
6/*
7 * Copyright (C) 2007 innotek GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef ___VBox_pdmasynccompletion_h
28#define ___VBox_pdmasynccompletion_h
29
30#include <VBox/types.h>
31#include <VBox/err.h>
32#include <iprt/assert.h>
33
34__BEGIN_DECLS
35
36/** @defgroup grp_pdm_async_completion Async I/O Completion
37 * @ingroup grp_pdm
38 * @{
39 */
40
41/** Pointer to a PDM async completion template handle. */
42typedef struct PDMASYNCCOMPLETIONTEMPLATE *PPDMASYNCCOMPLETIONTEMPLATE;
43/** Pointer to a PDM async completion template handle pointer. */
44typedef PPDMASYNCCOMPLETIONTEMPLATE *PPPDMASYNCCOMPLETIONTEMPLATE;
45
46/** Pointer to a PDM async completion task handle. */
47typedef struct PDMASYNCCOMPLETIONTASK *PPDMASYNCCOMPLETIONTASK;
48/** Pointer to a PDM async completion task handle pointer. */
49typedef PPDMASYNCCOMPLETIONTASK *PPPDMASYNCCOMPLETIONTASK;
50
51
52/**
53 * Completion callback for devices.
54 *
55 * @param pDevIns The device instance.
56 * @param pTask Pointer to the completion task.
57 * The task is at the time of the call setup to be resumed. So, the callback must
58 * call PDMR3AsyncCompletionSuspend or PDMR3AsyncCompletionDestroy if any other
59 * action is wanted upon return.
60 * @param pvCtx Pointer to any additional, OS specific, completion context. TBD.
61 * @param pvUser User argument.
62 */
63typedef DECLCALLBACK(void) FNPDMASYNCCOMPLETEDEV(PPDMDEVINS pDevIns, PPDMASYNCCOMPLETIONTASK pTask, void *pvCtx, void *pvUser);
64/** Pointer to a FNPDMASYNCCOMPLETEDEV(). */
65typedef FNPDMASYNCCOMPLETEDEV *PFNPDMASYNCCOMPLETEDEV;
66
67
68/**
69 * Completion callback for drivers.
70 *
71 * @param pDrvIns The driver instance.
72 * @param pTask Pointer to the completion task.
73 * The task is at the time of the call setup to be resumed. So, the callback must
74 * call PDMR3AsyncCompletionSuspend or PDMR3AsyncCompletionDestroy if any other
75 * action is wanted upon return.
76 * @param pvCtx Pointer to any additional, OS specific, completion context. TBD.
77 * @param pvUser User argument.
78 */
79typedef DECLCALLBACK(void) FNPDMASYNCCOMPLETEDRV(PPDMDRVINS pDrvIns, PPDMASYNCCOMPLETIONTASK pTask, void *pvCtx, void *pvUser);
80/** Pointer to a FNPDMASYNCCOMPLETEDRV(). */
81typedef FNPDMASYNCCOMPLETEDRV *PFNPDMASYNCCOMPLETEDRV;
82
83
84/**
85 * Completion callback for USB devices.
86 *
87 * @param pUsbIns The USB device instance.
88 * @param pTask Pointer to the completion task.
89 * The task is at the time of the call setup to be resumed. So, the callback must
90 * call PDMR3AsyncCompletionSuspend or PDMR3AsyncCompletionDestroy if any other
91 * action is wanted upon return.
92 * @param pvCtx Pointer to any additional, OS specific, completion context. TBD.
93 * @param pvUser User argument.
94 */
95typedef DECLCALLBACK(void) FNPDMASYNCCOMPLETEUSB(PPDMUSBINS pUsbIns, PPDMASYNCCOMPLETIONTASK pTask, void *pvCtx, void *pvUser);
96/** Pointer to a FNPDMASYNCCOMPLETEUSB(). */
97typedef FNPDMASYNCCOMPLETEUSB *PFNPDMASYNCCOMPLETEUSB;
98
99
100/**
101 * Completion callback for internal.
102 *
103 * @param pVM Pointer to the shared VM structure.
104 * @param pTask Pointer to the completion task.
105 * The task is at the time of the call setup to be resumed. So, the callback must
106 * call PDMR3AsyncCompletionSuspend or PDMR3AsyncCompletionDestroy if any other
107 * action is wanted upon return.
108 * @param pvCtx Pointer to any additional, OS specific, completion context. TBD.
109 * @param pvUser User argument for the task.
110 * @param pvUser2 User argument for the template.
111 */
112typedef DECLCALLBACK(void) FNPDMASYNCCOMPLETEINT(PVM pVM, PPDMASYNCCOMPLETIONTASK pTask, void *pvCtx, void *pvUser, void *pvUser2);
113/** Pointer to a FNPDMASYNCCOMPLETEINT(). */
114typedef FNPDMASYNCCOMPLETEINT *PFNPDMASYNCCOMPLETEINT;
115
116
117/**
118 * Creates a async completion template for a device instance.
119 *
120 * The template is used when creating new completion tasks.
121 *
122 * @returns VBox status code.
123 * @param pVM Pointer to the shared VM structure.
124 * @param pDevIns The device instance.
125 * @param ppTemplate Where to store the template pointer on success.
126 * @param pfnCompleted The completion callback routine.
127 * @param pszDesc Description.
128 */
129PDMR3DECL(int) PDMR3AsyncCompletionTemplateCreateDevice(PVM pVM, PPDMDEVINS pDevIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEDEV pfnCompleted, const char *pszDesc);
130
131/**
132 * Creates a async completion template for a driver instance.
133 *
134 * The template is used when creating new completion tasks.
135 *
136 * @returns VBox status code.
137 * @param pVM Pointer to the shared VM structure.
138 * @param pDrvIns The driver instance.
139 * @param ppTemplate Where to store the template pointer on success.
140 * @param pfnCompleted The completion callback routine.
141 * @param pszDesc Description.
142 */
143PDMR3DECL(int) PDMR3AsyncCompletionTemplateCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEDRV pfnCompleted, const char *pszDesc);
144
145/**
146 * Creates a async completion template for a USB device instance.
147 *
148 * The template is used when creating new completion tasks.
149 *
150 * @returns VBox status code.
151 * @param pVM Pointer to the shared VM structure.
152 * @param pUsbIns The USB device instance.
153 * @param ppTemplate Where to store the template pointer on success.
154 * @param pfnCompleted The completion callback routine.
155 * @param pszDesc Description.
156 */
157PDMR3DECL(int) PDMR3AsyncCompletionTemplateCreateUsb(PVM pVM, PPDMUSBINS pUsbIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEUSB pfnCompleted, const char *pszDesc);
158
159/**
160 * Creates a async completion template for internally by the VMM.
161 *
162 * The template is used when creating new completion tasks.
163 *
164 * @returns VBox status code.
165 * @param pVM Pointer to the shared VM structure.
166 * @param ppTemplate Where to store the template pointer on success.
167 * @param pfnCompleted The completion callback routine.
168 * @param pvUser2 The 2nd user argument for the callback.
169 * @param pszDesc Description.
170 */
171PDMR3DECL(int) PDMR3AsyncCompletionTemplateCreateInternal(PVM pVM, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEINT pfnCompleted, void *pvUser2, const char *pszDesc);
172
173/**
174 * Destroys the specified async completion template.
175 *
176 * @returns VBox status codes:
177 * @retval VINF_SUCCESS on success.
178 * @retval VERR_PDM_ASYNC_TEMPLATE_BUSY if the template is still in use.
179 *
180 * @param pTemplate The template in question.
181 */
182PDMR3DECL(int) PDMR3AsyncCompletionTemplateDestroy(PPDMASYNCCOMPLETIONTEMPLATE pTemplate);
183
184/**
185 * Destroys all the specified async completion templates for the given device instance.
186 *
187 * @returns VBox status codes:
188 * @retval VINF_SUCCESS on success.
189 * @retval VERR_PDM_ASYNC_TEMPLATE_BUSY if one or more of the templates are still in use.
190 *
191 * @param pVM Pointer to the shared VM structure.
192 * @param pDevIns The device instance.
193 */
194PDMR3DECL(int) PDMR3AsyncCompletionTemplateDestroyDevice(PVM pVM, PPDMDEVINS pDevIns);
195
196/**
197 * Destroys all the specified async completion templates for the given driver instance.
198 *
199 * @returns VBox status codes:
200 * @retval VINF_SUCCESS on success.
201 * @retval VERR_PDM_ASYNC_TEMPLATE_BUSY if one or more of the templates are still in use.
202 *
203 * @param pVM Pointer to the shared VM structure.
204 * @param pDrvIns The driver instance.
205 */
206PDMR3DECL(int) PDMR3AsyncCompletionTemplateDestroyDriver(PVM pVM, PPDMDRVINS pDrvIns);
207
208/**
209 * Destroys all the specified async completion templates for the given USB device instance.
210 *
211 * @returns VBox status codes:
212 * @retval VINF_SUCCESS on success.
213 * @retval VERR_PDM_ASYNC_TEMPLATE_BUSY if one or more of the templates are still in use.
214 *
215 * @param pVM Pointer to the shared VM structure.
216 * @param pUsbIns The USB device instance.
217 */
218PDMR3DECL(int) PDMR3AsyncCompletionTemplateDestroyUsb(PVM pVM, PPDMUSBINS pUsbIns);
219
220/**
221 * Async completion task type
222 */
223typedef enum PDMASYNCCOMPLETIONTASKTYPE
224{
225 /** Socket. */
226 PDMASYNCCOMPLETIONTASKTYPE_SOCKET = 0,
227 /** Host OS specific. */
228 PDMASYNCCOMPLETIONTASKTYPE_HOST,
229 /** Number of supported backends. This has to be last entry! */
230 PDMASYNCCOMPLETIONTASKTYPE_SUPPORTED
231} PDMASYNCCOMPLETIONTASKTYPE;
232
233/**
234 * Get the backend name of a task type.
235 *
236 * @returns Name of the backend.
237 * @param enmTaskType The task type to get the backend name from.
238 */
239PDMR3DECL(const char *) PDMR3AsyncCompletionGetBackendName(PDMASYNCCOMPLETIONTASKTYPE enmTaskType);
240
241/**
242 * Creates a completion task.
243 *
244 * @returns VBox status code.
245 * @param ppTask Where to store the task handle on success.
246 * @param pTemplate The async completion template.
247 * @param enmType The type of the task.
248 * @param pvCtx The task specific context.
249 * @param pvUser The user argument for the callback.
250 */
251PDMR3DECL(int) PDMR3AsyncCompletionTaskCreate(PPPDMASYNCCOMPLETIONTASK ppTask, PPDMASYNCCOMPLETIONTEMPLATE pTemplate, PDMASYNCCOMPLETIONTASKTYPE enmType, void *pvCtx, void *pvUser);
252
253/**
254 * Associate a task with a type specific context.
255 *
256 * @returns VBox status code.
257 * @param pTask The task to associate the context with.
258 * @param pvCtx Pointer to the context.
259 */
260PDMR3DECL(int) PDMR3AsyncCompletionTaskAssociate(PPDMASYNCCOMPLETIONTASK pTask, void *pvCtx);
261
262/**
263 * Start processing the task handle.
264 * The task must have a type specific context.
265 *
266 * @returns VBox status code.
267 * @param pTask Pointer to the task which should be submited.
268 */
269PDMR3DECL(int) PDMR3AsyncCompletionTaskSubmit(PPDMASYNCCOMPLETIONTASK pTask);
270
271/**
272 * Sets the user argument of a completion task.
273 *
274 * @returns VBox status code.
275 * @param pTask The async completion task.
276 * @param pvUser The user argument for the callback.
277 */
278PDMR3DECL(int) PDMR3AsyncCompletionTaskSetUserArg(PPDMASYNCCOMPLETIONTASK pTask, void *pvUser);
279
280/**
281 * Suspends a async completion task.
282 *
283 * @returns VBox status codes:
284 * @retval VINF_SUCCESS on success.
285 * @retval VERR_PDM_ASYNC_COMPLETION_ALREADY_SUSPENDED if already suspended.
286 * @retval VERR_INVALID_HANDLE if pTask is invalid (asserts).
287 * @param pTask The async completion task.
288 */
289PDMR3DECL(int) PDMR3AsyncCompletionTaskSuspend(PPDMASYNCCOMPLETIONTASK pTask);
290
291/**
292 * Suspends a async completion task.
293 *
294 * @returns VBox status codes:
295 * @retval VINF_SUCCESS on success.
296 * @retval VERR_PDM_ASYNC_COMPLETION_NOT_SUSPENDED if not suspended.
297 * @retval VERR_INVALID_HANDLE if pTask is invalid (asserts).
298 * @param pTask The async completion task.
299 */
300PDMR3DECL(int) PDMR3AsyncCompletionTaskResume(PPDMASYNCCOMPLETIONTASK pTask);
301
302/**
303 * Cancels a async completion task.
304 * The task doesn't have to be suspended.
305 *
306 * @returns VBox status code
307 * @param pTask The Task to cancel.
308 */
309PDMR3DECL(int) PDMR3AsyncCompletionTaskCancel(PPDMASYNCCOMPLETIONTASK pTask);
310
311/**
312 * Destroys a async completion task.
313 *
314 * The task doesn't have to be suspended or anything.
315 *
316 * @returns VBox status codes:
317 * @retval VINF_SUCCESS on success.
318 * @retval VERR_INVALID_HANDLE if pTask is invalid but not NIL (asserts).
319 * @param pTask The async completion task.
320 */
321PDMR3DECL(int) PDMR3AsyncCompletionTaskDestroy(PPDMASYNCCOMPLETIONTASK pTask);
322
323/*
324 * Host specific wrapper functions for the above API
325 */
326#if defined(RT_OS_LINUX)
327
328struct iocb;
329
330/**
331 * Creates a completion task for an IO operation on Linux.
332 *
333 * The pvCtx callback argument will be pIoCB.
334 *
335 * @returns VBox status code.
336 * @param ppTask Where to store the task handle on success.
337 * @param pTemplate The async completion template.
338 * @param pIoCB The asynchronous I/O control block to wait for.
339 * @param pvUser The user argument for the callback.
340 */
341DECLINLINE(int) PDMR3AsyncCompletionCreateLnxIO(PPPDMASYNCCOMPLETIONTASK ppTask, PPDMASYNCCOMPLETIONTEMPLATE pTemplate, const struct iocb *pIoCB, void *pvUser)
342{
343 int rc = VINF_SUCCESS;
344 PPDMASYNCCOMPLETIONTASK pTask;
345
346 rc = PDMR3AsyncCompletionTaskCreate(&pTask, pTemplate, PDMASYNCCOMPLETIONTASKTYPE_HOST, (void *)pIoCB, pvUser);
347 if (VBOX_FAILURE(rc))
348 {
349 AssertMsgFailed(("Creating Linux task failed\n"));
350 return rc;
351 }
352
353 rc = PDMR3AsyncCompletionTaskSubmit(pTask);
354 if (VBOX_FAILURE(rc))
355 {
356 AssertMsgFailed(("Submitting Linux task failed\n"));
357 PDMR3AsyncCompletionTaskDestroy(pTask);
358 return rc;
359 }
360
361 *ppTask = pTask;
362
363 return rc;
364}
365#endif /* RT_OS_LINUX */
366
367#if defined(RT_OS_SOLARIS) || defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX)
368
369struct aiocb;
370
371/**
372 * Creates a completion task for an AIO operation on Unix like systems like Solaris, Darwin or FreeBSD.
373 * This method must be used too on Linux if the real asynchronous solution is not available.
374 *
375 * The pvCtx callback argument will be pAioCB.
376 *
377 * @returns VBox status code.
378 * @param ppTask Where to store the task handle on success.
379 * @param pTemplate The async completion template.
380 * @param pIoCB The asynchronous I/O control block to wait for.
381 * @param pvUser The user argument for the callback.
382 */
383DECLINLINE(int) PDMR3AsyncCompletionCreateUnxAIO(PPPDMASYNCCOMPLETIONTASK ppTask, PPDMASYNCCOMPLETIONTEMPLATE pTemplate, const struct aiocb *pAioCB, void *pvUser)
384{
385 int rc = VINF_SUCCESS;
386 PPDMASYNCCOMPLETIONTASK pTask;
387
388 rc = PDMR3AsyncCompletionTaskCreate(&pTask, pTemplate, PDMASYNCCOMPLETIONTASKTYPE_HOST, (void *)pAioCB, pvUser);
389 if (VBOX_FAILURE(rc))
390 {
391 AssertMsgFailed(("Creating AIO task failed\n"));
392 return rc;
393 }
394
395 rc = PDMR3AsyncCompletionTaskSubmit(pTask);
396 if (VBOX_FAILURE(rc))
397 {
398 AssertMsgFailed(("Submitting AIO task failed\n"));
399 PDMR3AsyncCompletionTaskDestroy(pTask);
400 return rc;
401 }
402
403 *ppTask = pTask;
404
405 return rc;
406}
407#endif /* RT_OS_SOLARIS || RT_OS_DARWIN || RT_OS_FREEBSD || RT_OS_LINUX */
408
409#ifdef RT_OS_OS2
410/**
411 * Creates a completion task for an event semaphore on OS/2.
412 *
413 * The pvCtx callback argument will be hev.
414 *
415 * @returns VBox status code.
416 * @param ppTask Where to store the task handle on success.
417 * @param pTemplate The async completion template.
418 * @param hev The handle of the event semaphore to wait on.
419 * @param pvUser The user argument for the callback.
420 */
421DECLINLINE(int) PDMR3AsyncCompletionCreateOs2Event(PPPDMASYNCCOMPLETIONTASK ppTask, PPDMASYNCCOMPLETIONTEMPLATE pTemplate, unsigned long hev, void *pvUser)
422{
423 int rc = VINF_SUCCESS;
424 PPDMASYNCCOMPLETIONTASK pTask;
425
426 rc = PDMR3AsyncCompletionTaskCreate(&pTask, pTemplate, PDMASYNCCOMPLETIONTASKTYPE_HOST, (void *)&hev, pvUser);
427 if (VBOX_FAILURE(rc))
428 {
429 AssertMsgFailed(("Creating OS/2 task failed\n"));
430 return rc;
431 }
432
433 rc = PDMR3AsyncCompletionTaskSubmit(pTask);
434 if (VBOX_FAILURE(rc))
435 {
436 AssertMsgFailed(("Submitting OS/2 task failed\n"));
437 PDMR3AsyncCompletionTaskDestroy(pTask);
438 return rc;
439 }
440
441 *ppTask = pTask;
442
443 return rc;
444}
445#endif /* RT_OS_OS2 */
446
447#ifdef RT_OS_WINDOWS
448/**
449 * Creates a completion task for an object on Windows.
450 *
451 * The pvCtx callback argument will be hObject.
452 *
453 * @returns VBox status code.
454 * @param ppTask Where to store the task handle on success.
455 * @param pTemplate The async completion template.
456 * @param hObject The object to wait for.
457 * @param pvUser The user argument for the callback.
458 */
459DECLINLINE(int) PDMR3AsyncCompletionCreateWinObject(PPPDMASYNCCOMPLETIONTASK ppTask, PPDMASYNCCOMPLETIONTEMPLATE pTemplate, void *hObject, void *pvUser)
460{
461 int rc = VINF_SUCCESS;
462 PPDMASYNCCOMPLETIONTASK pTask;
463
464 rc = PDMR3AsyncCompletionTaskCreate(&pTask, pTemplate, PDMASYNCCOMPLETIONTASKTYPE_HOST, (void *)hObject, pvUser);
465 if (VBOX_FAILURE(rc))
466 {
467 AssertMsgFailed(("Creating Windows task failed\n"));
468 return rc;
469 }
470
471 rc = PDMR3AsyncCompletionTaskSubmit(pTask);
472 if (VBOX_FAILURE(rc))
473 {
474 AssertMsgFailed(("Submitting Windows task failed\n"));
475 PDMR3AsyncCompletionTaskDestroy(pTask);
476 return rc;
477 }
478
479 *ppTask = pTask;
480
481 return rc;
482}
483#endif /* RT_OS_WINDOWS */
484
485/**
486 * Socket completion context (pvCtx).
487 */
488typedef struct PDMASYNCCOMPLETIONSOCKET
489{
490 /** The socket. */
491 RTSOCKET Socket;
492 /** Readable. */
493 bool fReadable;
494 /** Writable. */
495 bool fWriteable;
496 /** Exceptions. */
497 bool fXcpt;
498} PDMASYNCCOMPLETIONSOCKET;
499/** Pointer to a socket completion context. */
500typedef PDMASYNCCOMPLETIONSOCKET *PPDMASYNCCOMPLETIONSOCKET;
501
502/**
503 * Creates a completion task for a socket.
504 *
505 * The pvCtx callback argument will be pointing to a PDMASYNCCOMPLETIONSOCKET structure.
506 *
507 * @returns VBox status code.
508 * @param ppTask Where to store the task handle on success.
509 * @param pTemplate The async completion template.
510 * @param Socket The socket.
511 * @param fReadable Whether to callback when the socket becomes readable.
512 * @param fWriteable Whether to callback when the socket becomes writable.
513 * @param fXcpt Whether to callback on exception.
514 * @param pvUser The user argument for the callback.
515 */
516DECLINLINE(int) PDMR3AsyncCompletionCreateSocket(PPPDMASYNCCOMPLETIONTASK ppTask, PPDMASYNCCOMPLETIONTEMPLATE pTemplate, RTSOCKET Socket, bool fReadable, bool fWriteable, bool fXcpt, void *pvUser)
517{
518 int rc = VINF_SUCCESS;
519 PPDMASYNCCOMPLETIONTASK pTask;
520 PDMASYNCCOMPLETIONSOCKET SocketContext;
521
522 SocketContext.Socket = Socket;
523 SocketContext.fReadable = fReadable;
524 SocketContext.fWriteable = fWriteable;
525 SocketContext.fXcpt = fXcpt;
526
527 rc = PDMR3AsyncCompletionTaskCreate(&pTask, pTemplate, PDMASYNCCOMPLETIONTASKTYPE_SOCKET, (void *)&SocketContext, pvUser);
528 if (VBOX_FAILURE(rc))
529 {
530 AssertMsgFailed(("Creating Socket task failed\n"));
531 return rc;
532 }
533
534 rc = PDMR3AsyncCompletionTaskSubmit(pTask);
535 if (VBOX_FAILURE(rc))
536 {
537 AssertMsgFailed(("Submitting Socket task failed\n"));
538 PDMR3AsyncCompletionTaskDestroy(pTask);
539 return rc;
540 }
541
542 *ppTask = pTask;
543
544 return rc;
545}
546
547/**
548 * Modifies a socket completion task.
549 *
550 * @returns VBox status code.
551 * @retval VINF_SUCCESS on success.
552 * @retval VERR_NOT_SUPPORTED if the task isn't a socket task.
553 * @param pTemplate The async completion template.
554 * @param Socket The socket
555 * @param fReadable Whether to callback when the socket becomes readable.
556 * @param fWriteable Whether to callback when the socket becomes writable.
557 * @param fXcpt Whether to callback on exception.
558 */
559DECLINLINE(int) PDMR3AsyncCompletionModifySocket(PPDMASYNCCOMPLETIONTASK pTask, RTSOCKET Socket, bool fReadable, bool fWriteable, bool fXcpt)
560{
561 int rc = VINF_SUCCESS;
562 PDMASYNCCOMPLETIONSOCKET SocketContext;
563
564 SocketContext.Socket = Socket;
565 SocketContext.fReadable = fReadable;
566 SocketContext.fWriteable = fWriteable;
567 SocketContext.fXcpt = fXcpt;
568
569 rc = PDMR3AsyncCompletionTaskAssociate(pTask, &SocketContext);
570 if (VBOX_FAILURE(rc))
571 {
572 AssertMsgFailed(("Modifying Socket task failed\n"));
573 return rc;
574 }
575
576 return rc;
577}
578
579/** @} */
580
581__END_DECLS
582
583#endif
584
585
586
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette