browserutilities/feedsengine/FeedsServer/Server/src/Task.cpp
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Task base class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "Task.h"
       
    21 
       
    22 // -----------------------------------------------------------------------------
       
    23 // CTask::CTask
       
    24 // C++ default constructor can NOT contain any code, that
       
    25 // might leave.
       
    26 // -----------------------------------------------------------------------------
       
    27 //
       
    28 CTask::CTask(CFeedsServer& aFeedsServer):
       
    29         iFeedsServer(aFeedsServer)
       
    30     {
       
    31     }
       
    32         
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CTask::~CTask
       
    36 // Deconstructor.
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CTask::~CTask()
       
    40     {
       
    41     delete iAutoDelete;
       
    42     }
       
    43 
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CTask::ConstructL
       
    47 // Symbian 2nd phase constructor can leave.
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 void CTask::BaseConstructL(TBool aAutoDelete)
       
    51     {
       
    52     if (aAutoDelete)
       
    53         {        
       
    54         iAutoDelete = CIdle::NewL(CActive::EPriorityIdle);
       
    55         }
       
    56     }        
       
    57 
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CTask::AutoDelete
       
    61 //
       
    62 // Starts an CIdle to delete the instance after the callstack has unrolled.
       
    63 // -----------------------------------------------------------------------------
       
    64 //    
       
    65 void CTask::AutoDelete()
       
    66     {
       
    67     if (iAutoDelete != NULL)
       
    68         {
       
    69         iAutoDelete->Start(TCallBack(DelayedDelete, this));
       
    70         }
       
    71     else
       
    72         {
       
    73         // TODO: Panic.
       
    74         }
       
    75     }
       
    76 
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CTask::DelayedDelete
       
    80 // 
       
    81 // Deletes the instance after the callstack has unrolled.
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 TInt CTask::DelayedDelete(TAny* aPtr)
       
    85     {
       
    86     CTask*  self = static_cast<CTask*>(aPtr);
       
    87     
       
    88     delete self;    
       
    89     return EFalse;
       
    90     }