Symbian3/SDK/Source/GUID-18182059-859D-51CF-A940-D230D9F9CF8C.dita
changeset 7 51a74ef9ed63
parent 0 89d6a7a84779
equal deleted inserted replaced
6:43e37759235e 7:51a74ef9ed63
       
     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-18182059-859D-51CF-A940-D230D9F9CF8C" xml:lang="en"><title>How
       
    13 to allocate and de-allocate cleanup stacks</title><shortdesc>This document describes when and how a cleanup stack should be
       
    14 allocated and de-allocated.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    15 <p>The main categories of programs (GUI applications and servers) both have
       
    16 cleanup stacks created for them as part of their respective frameworks. Simple
       
    17 console programs for test and demonstration purposes though require a cleanup
       
    18 stack to be explicitly allocated. </p>
       
    19 <p>Allocate the stack at the beginning of the thread as follows:</p>
       
    20 <codeblock id="GUID-204BB8EA-016F-53CA-BB22-17B685BFF18A" xml:space="preserve">TheTrapCleanup=CTrapCleanup::New();</codeblock>
       
    21 <p>De-allocate the cleanup stack at the end of the thread as follows:</p>
       
    22 <codeblock id="GUID-C8A45849-E86C-5DA6-B1A5-88113B06C2B7" xml:space="preserve">delete TheTrapCleanup;</codeblock>
       
    23 <section id="GUID-9E86AB70-D551-4356-9001-749FBE8B2DCE"><title>Notes</title> <ul>
       
    24 <li id="GUID-37929EEE-F608-5754-9324-6731FEA5B1B2"><p>This explicit allocation
       
    25 and de-allocation is necessary for threads which use cleanup processing. Threads
       
    26 which do not use cleanup stack processing need not allocate a cleanup stack. </p> </li>
       
    27 <li id="GUID-6B30E7F5-1D29-50EF-8896-0CD8400BBBCF"><p>Note that the cleanup
       
    28 stack variable name (<codeph>TheTrapCleanup</codeph> in this case) is only
       
    29 used to reference the stack when it needs to be destroyed. Therefore the user
       
    30 is at liberty to give the stack any valid variable name. Multiple cleanup
       
    31 stacks are supported: the system holds a stack of cleanup stacks, of which
       
    32 the top item is the current cleanup stack. As such, when a new stack is created
       
    33 it is pushed onto the stack of cleanup stacks, making it the current cleanup
       
    34 stack. When it is destroyed, it is pushed off the stack of cleanup stacks
       
    35 making the previously stacked cleanup stack the current one.</p> </li>
       
    36 </ul> </section>
       
    37 </conbody></concept>