VirtualBox

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

Last change on this file since 8299 was 8155, checked in by vboxsync, 17 years ago

The Big Sun Rebranding Header Change

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