omxil/xmltestharness/xmlclient/src/threadedlogger.h
branchOpenMAX-IL_SHAI
changeset 16 eedf2dcd43c6
equal deleted inserted replaced
15:c1e808730d6c 16:eedf2dcd43c6
       
     1 /*
       
     2 * Copyright (c) 2009 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 "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:
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef THREADEDLOGGER_H_
       
    19 #define THREADEDLOGGER_H_
       
    20 
       
    21 #include "omx_xml_script.h"
       
    22 
       
    23 /**
       
    24  * Adapter class that serializes all Log() calls on the underlying logger into the same thread.
       
    25  * That is, a call to Log() from a thread that did not create this AO will block until the AO has
       
    26  * completed the log in the AS thread.
       
    27  * 
       
    28  * This class is provided to allow the use of loggers that would otherwise KERN-EXEC 0 panic if
       
    29  * used by multiple threads.
       
    30  */
       
    31 class CThreadedLogger : public CActive, public MOmxScriptTestLogger
       
    32 	{
       
    33 public:
       
    34 	static CThreadedLogger* NewLC(MOmxScriptTestLogger& aRealLogger);
       
    35 	~CThreadedLogger();
       
    36 	
       
    37 	void Log(const TText8* aFile, TInt aLine, TOmxScriptSeverity aSeverity, const TDes& aMessage);
       
    38 	
       
    39 private:
       
    40 	CThreadedLogger(MOmxScriptTestLogger& aRealLogger);
       
    41 	void ConstructL();
       
    42 	
       
    43 	void RunL();
       
    44 	void DoCancel();
       
    45 	
       
    46 private:
       
    47 	MOmxScriptTestLogger& iRealLogger;
       
    48 	RThread iCreatorThread;
       
    49 	RMutex iMutex;
       
    50 	RSemaphore iSemaphore;
       
    51 	TThreadId iCreatorThreadId;
       
    52 	
       
    53 	TText8* iFile;
       
    54 	TInt iLine;
       
    55 	TOmxScriptSeverity iSeverity;
       
    56 	TDes* iMessage;
       
    57 	};
       
    58 
       
    59 #endif /* THREADEDLOGGER_H_ */