|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE concept |
|
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
|
12 <concept id="GUID-0E93319A-439E-49D8-BF38-C809FEE4BB74" xml:lang="en"><title>User-side |
|
13 Creation</title><shortdesc>This document describes user-side creation of asynchronous requests.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
14 <p>Asynchronous requests are commonly initiated by a call to <xref href="GUID-6FBFA078-8253-3E24-B1F8-5F75E86C3066.dita#GUID-6FBFA078-8253-3E24-B1F8-5F75E86C3066/GUID-FCC4A3A9-69F5-3947-8D0F-2AD12086F1E2"><apiname>RBusLogicalChannel::DoRequest()</apiname></xref>. |
|
15 The user making an asynchronous request creates a <xref href="GUID-E0B34F3E-D4C4-3232-B8B1-7DB35B454646.dita"><apiname>TRequestStatus</apiname></xref> object |
|
16 and passes it along with the request type to the <xref href="GUID-9D910016-5611-30DD-A139-EE46705A4912.dita"><apiname>DoRequest()</apiname></xref> call. |
|
17 The request status is changed to <xref href="GUID-B0778F54-C5DD-3307-A1E2-0DD339C4E4E7.dita"><apiname>KRequestPending</apiname></xref> by the |
|
18 Kernel before sending the message to the driver. The user may then either |
|
19 wait on the request using <xref href="GUID-C197C9A7-EA05-3F24-9854-542E984C612D.dita#GUID-C197C9A7-EA05-3F24-9854-542E984C612D/GUID-50223158-D05D-33FE-A3DD-FFA9E2F464FF"><apiname>User::WaitForRequest()</apiname></xref>, or it |
|
20 may queue one or more requests and then wait. It may have an active object |
|
21 handler to receive the request complete notifications. </p> |
|
22 <codeblock id="GUID-39AC44C2-1FDF-5A6C-81F0-0BA9BB23DF91" xml:space="preserve">// Request status object for transmit. This object will be used to |
|
23 // read the status of asynchronous requests after the notification of |
|
24 // request completion |
|
25 // |
|
26 TRequestStatus txStatus; |
|
27 |
|
28 // Call the LDD interface TransmitData() API with test data descriptor |
|
29 // and TRequestStatus object as parameters. Here TransmitData() is a |
|
30 // wrapper over a DoRequest() call. |
|
31 // |
|
32 r = ldd.TransmitData(txStatus, KTestSendData); |
|
33 test(r==KErrNone); |
|
34 |
|
35 // Wait till the request is complete on txStatus. The user thread is |
|
36 // blocked with this call, till it is notified about the request |
|
37 // completion. |
|
38 // |
|
39 User::WaitForRequest(txStatus); |
|
40 |
|
41 // txStatus holds the request completion. TRequestStatus::Int() |
|
42 // returns the completion code. It will be KErrNone in case of |
|
43 // successful completion. |
|
44 // |
|
45 r = txStatus.Int(); |
|
46 test(r==KErrNone);</codeblock> |
|
47 </conbody></concept> |