1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/inc/mmf/server/mmfsubthreadbaseimpl.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,116 @@
1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef __MMFSUBTHREADBASE_IMPL_H__
1.20 +#define __MMFSUBTHREADBASE_IMPL_H__
1.21 +
1.22 +#include <e32base.h>
1.23 +#include <e32std.h>
1.24 +#include <mmf/common/mmfpaniccodes.h>
1.25 +#include <mmf/common/mmfcontroller.h>
1.26 +#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
1.27 +#include <mmf/common/mmfipcserver.h>
1.28 +#endif
1.29 +
1.30 +
1.31 +/**
1.32 +@internalTechnology
1.33 +
1.34 +Used to Kill the subthread either immediately or after a timeout.
1.35 +Used by the subthread on startup to prevent orphaning if no sessions are created to it.
1.36 +*/
1.37 +class CMMFSubThreadShutdown : public CTimer
1.38 + {
1.39 + enum {EMMFSubThreadShutdownDelay=1000000}; // 1s
1.40 +public:
1.41 + static CMMFSubThreadShutdown* NewL();
1.42 + CMMFSubThreadShutdown();
1.43 + void ConstructL();
1.44 + void Start();
1.45 + void ShutdownNow();
1.46 +private:
1.47 + void RunL();
1.48 + };
1.49 +
1.50 +/**
1.51 +@internalTechnology
1.52 +
1.53 +Subthread server base class.
1.54 +Provides session counting and will kill the subthread immediately when the session count reaches zero.
1.55 +Starts the shutdown timer on construction to prevent orphaning if no sessions are created.
1.56 +*/
1.57 +class CMMFSubThreadServer : public CMmfIpcServer
1.58 + {
1.59 +public:
1.60 + virtual ~CMMFSubThreadServer();
1.61 + virtual void SessionCreated();
1.62 + virtual TInt RunError(TInt aError);
1.63 + virtual void ShutdownNow();
1.64 +protected:
1.65 + virtual CMmfIpcSession* NewSessionL(const TVersion& aVersion) const = 0;
1.66 + CMMFSubThreadServer(TInt aPriority);
1.67 + void ConstructL();
1.68 +private:
1.69 + CMMFSubThreadShutdown* iShutdownTimer;
1.70 + };
1.71 +
1.72 +/**
1.73 +@internalTechnology
1.74 +
1.75 +Used to hold on to an RMessage so we can complete it asynchronously to send an event to the main thread.
1.76 +*/
1.77 +class CMMFSubThreadEventReceiver : public CBase
1.78 + {
1.79 +public:
1.80 + static CMMFSubThreadEventReceiver* NewL(const RMmfIpcMessage& aMessage);
1.81 + ~CMMFSubThreadEventReceiver();
1.82 + void SendEvent(const TMMFEvent& aEvent);
1.83 +private:
1.84 + CMMFSubThreadEventReceiver(const RMmfIpcMessage& aMessage);
1.85 +private:
1.86 + RMmfIpcMessage iMessage;
1.87 + TBool iNeedToCompleteMessage;
1.88 + };
1.89 +
1.90 +/**
1.91 +@internalTechnology
1.92 +
1.93 +Subthread session base class.
1.94 +Derived classes must implement the ServiceL() method.
1.95 +*/
1.96 +class CMMFSubThreadSession : public CMmfIpcSession, public MAsyncEventHandler
1.97 + {
1.98 +public:
1.99 + virtual ~CMMFSubThreadSession();
1.100 + void CreateL(const CMmfIpcServer& aServer);
1.101 + virtual void ServiceL(const RMmfIpcMessage& aMessage) = 0;
1.102 + //from MAsyncEventHandler
1.103 + TInt SendEventToClient(const TMMFEvent& aEvent);
1.104 +protected:
1.105 + CMMFSubThreadSession() {};
1.106 + TBool ReceiveEventsL(const RMmfIpcMessage& aMessage);
1.107 + TBool CancelReceiveEvents();
1.108 + TBool ShutDown();
1.109 +protected:
1.110 + CMMFSubThreadServer* iServer;
1.111 +private:
1.112 + CMMFSubThreadEventReceiver* iEventReceiver;
1.113 + RArray<TMMFEvent> iEvents;
1.114 + };
1.115 +
1.116 +
1.117 +
1.118 +#endif
1.119 +