imagingandcamerafws/imagingfws/src/GenThreadRelay.h
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __GEN_THREAD_RELAY_H__
       
    17 #define __GEN_THREAD_RELAY_H__
       
    18 
       
    19 #include "ImageConversion.h"
       
    20 
       
    21 const TThreadPriority KSubThreadPriority = EPriorityLess;
       
    22 const TInt KSubThreadStackSize = KDefaultStackSize;	// 0x2000 = 8k
       
    23 const TInt KTerminationFunction = 0;
       
    24 
       
    25 class CSubThreadRelay;
       
    26 
       
    27 /**
       
    28  *
       
    29  * This class is not for public use
       
    30  *
       
    31  */
       
    32 class TThreadRelayParam
       
    33 	{
       
    34 public:
       
    35 	TThreadId iMainThreadId;
       
    36 	CSubThreadRelay** iSubThreadRelay; //Not owned
       
    37 	CSubThreadRelay* (*iFactoryFunctionL) (TThreadId aMainThreadId, TAny* aCodecParam); //Not owned
       
    38 	TAny* iCodecParam; //Not owned
       
    39 	TRequestStatus* iSetupComplete; //Not owned
       
    40 	};
       
    41 
       
    42 class CSubThreadUndertaker; // declared here
       
    43 /**
       
    44  *
       
    45  * This class is not for public use
       
    46  * This AO monitor the sub thread for panics
       
    47  *
       
    48  */
       
    49 NONSHARABLE_CLASS( CSubThreadUndertaker ): public CActive
       
    50 	{
       
    51 public:
       
    52 	static CSubThreadUndertaker* NewL(RThread& aSubThread);
       
    53 	virtual ~CSubThreadUndertaker();
       
    54 
       
    55 protected:
       
    56 	//From CActive
       
    57 	virtual void RunL();
       
    58 	virtual void DoCancel();
       
    59 
       
    60 private:
       
    61 	CSubThreadUndertaker(RThread* aSubThread);
       
    62 
       
    63 private:
       
    64 	RThread* iSubThread; //Not owned
       
    65 	};
       
    66 
       
    67 class CSubThreadRelay; // declared here
       
    68 /**
       
    69  *
       
    70  * This class is not for public use
       
    71  * Implement plugin side thread interface for threaded De/Encode
       
    72  *
       
    73  */
       
    74 NONSHARABLE_CLASS( CSubThreadRelay ): public CActive
       
    75 	{
       
    76 public:
       
    77 	void Shutdown(TRequestStatus& aRequestStatus);
       
    78 	virtual ~CSubThreadRelay();
       
    79 
       
    80 	void Prime();
       
    81 	void SignalSetupComplete(TRequestStatus* aSetupComplete);
       
    82 
       
    83 	TRequestStatus* Status();
       
    84 
       
    85 	void RunFunctionInThread(TRequestStatus& aCallingStatus, TInt aFunctionCode, TAny* aParameters);
       
    86 	void SetSubThread(RThread* aSubThread);
       
    87 
       
    88 protected:
       
    89 	void ConstructL(TThreadId aMainThreadId);
       
    90 	CSubThreadRelay();
       
    91 
       
    92 	virtual void RunFunctionL(TInt aFunctionCode, TAny* aParameters) = 0;
       
    93 
       
    94 	//From CActive
       
    95 	virtual void RunL();
       
    96 	virtual void DoCancel();
       
    97 
       
    98 protected:
       
    99 	RThread iMainThread;
       
   100 	RThread* iSubThread; //Not owned
       
   101 
       
   102 private:
       
   103 	TRequestStatus* iCallingStatus;
       
   104 	TInt iFunctionCode;
       
   105 	TAny* iFunctionParams;
       
   106 	};
       
   107 
       
   108 class CThreadRelay; // declared here
       
   109 /**
       
   110  *
       
   111  * This class is not for public use
       
   112  * Implement client side thread interface for threaded De/Encoding
       
   113  *
       
   114  */
       
   115 NONSHARABLE_CLASS( CThreadRelay ): public CBase
       
   116 	{
       
   117 public:
       
   118 	virtual ~CThreadRelay();
       
   119 
       
   120 protected:
       
   121 	CThreadRelay();
       
   122 	void ConstructL(CSubThreadRelay* (*aFactoryFunctionL)(TThreadId aMainThreadId, TAny* aCodecParam), TAny* aCodecParam);
       
   123 
       
   124 	TInt RunFunction(TInt aFunctionCode, TAny* aParameters);
       
   125 
       
   126 	CSubThreadRelay* SubThreadRelay();
       
   127 
       
   128 	const RThread* SubThread() const;
       
   129 	void SetPriority(TThreadPriority aPriority) const;
       
   130 
       
   131 private:
       
   132 	static TInt ThreadFunction(TAny* aPtr);
       
   133 	static void ThreadTrapFunctionL(TAny* aPtr);
       
   134 	void Shutdown();
       
   135 
       
   136 private:
       
   137 	CSubThreadUndertaker* iSubThreadUndertaker;
       
   138 	CSubThreadRelay* iSubRelay;
       
   139 	RThread iSubThread;
       
   140 	TRequestStatus iFunctionCallStatus;
       
   141 	TBool iThreadCreated;
       
   142 	};
       
   143 
       
   144 
       
   145 #endif // __GEN_THREAD_RELAY_H__
       
   146