Adaptation/GUID-F367F6C9-66F7-4061-81A7-0C845D8F39C4.dita
changeset 15 307f4279f433
equal deleted inserted replaced
14:578be2adaf3e 15:307f4279f433
       
     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-F367F6C9-66F7-4061-81A7-0C845D8F39C4" xml:lang="en"><title>Cancellation
       
    13 of Asynchronous Requests</title><shortdesc>This document describes how a device driver cancels an asynchronous
       
    14 request.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    15 <p>Any outstanding asynchronous request can be cancelled. <xref href="GUID-675860FB-AA37-3467-AF52-7D1B17FEE0A6.dita"><apiname>DoCancel()</apiname></xref> is
       
    16 implemented to handle cancel requests. Cancel requests are either explicitly
       
    17 made by the user or made when there is a close message. Any pending requests
       
    18 and queued DFCs are cancelled and the request is completed with <xref href="GUID-6F4A88DA-F54E-3848-9C32-942D6F5F4F3E.dita"><apiname>KErrCancel</apiname></xref>. </p>
       
    19 <codeblock id="GUID-AEE32663-E6E2-50CC-A756-10CAC0CA503D" xml:space="preserve">/** 
       
    20  Cancel Asynchronous Requests. This is called from HandleMsg() to 
       
    21  cancel pending asynchronous requests. This function determines which    
       
    22  operation is to be cancelled and tidies up the resources specific to 
       
    23  the request being cancelled, any outstanding DFCs, and timers, and   
       
    24  signals the client that the operation is completed.
       
    25  
       
    26  @param aMask
       
    27  Mask containing the request number that has to be cancelled 
       
    28  */
       
    29 void DExDriverLogicalChannel::DoCancel(TUint aMask)
       
    30     {
       
    31     ...
       
    32     // Any pending asynchronous operation can be 
       
    33     // cancelled. Check a valid asynchronous request 
       
    34     // to cancel has been specified.
       
    35     //
       
    36     if(aMask&amp;(1&lt;&lt;RExDriverChannel::ERequestTransmitData))
       
    37         {
       
    38         if (iTxDataStatus)
       
    39             {
       
    40             // If it is a Transmit request, cancel the Transmit DFC. 
       
    41             // TDfc::Cancel() cancels the DFC if it is already 
       
    42             // queued. It does nothing if the DFC is not queued.
       
    43             //
       
    44             iTxDfc.Cancel();
       
    45 
       
    46             // Notify the client (iClient) that the request is 
       
    47             // completed. The TRequestStatus object is updated with the 
       
    48             // status and the completion code is provided to the
       
    49             // client. KErrCancel indicates that the request has been 
       
    50             // cancelled. Typically, a client thread, waiting on 
       
    51             // User::WaitForRequest(TRequestStatus &amp;aStatus) or using
       
    52             // the active object framework, is unblocked and notified. 
       
    53             // Then the client may read the request status from the 
       
    54             // TRequestStatus object. 
       
    55             //                                              
       
    56             Kern::RequestComplete(iClient,iTxDataStatus,KErrCancel);
       
    57             }
       
    58         }
       
    59     ...
       
    60     }</codeblock>
       
    61 </conbody></concept>