genericopenlibs/posixrealtimeextensions/inc/timerserver.h
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     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 __TIMERSERVER_H__
       
    19 #define __TIMERSERVER_H__
       
    20 
       
    21 #include <e32base.h>
       
    22 #include "timerutils.h"
       
    23 
       
    24 enum TMyPanic
       
    25 	{
       
    26 	EPanicBadDescriptor,
       
    27 	EPanicIllegalFunction,
       
    28 	EPanicAlreadyReceiving
       
    29 	};
       
    30 
       
    31 void PanicClient(const RMessagePtr2& aMessage,TMyPanic TMyPanic);
       
    32 
       
    33 NONSHARABLE_CLASS(CShutdown) : public CTimer
       
    34    {
       
    35 public:
       
    36     CShutdown() : CTimer(EPriorityStandard)
       
    37     	{
       
    38     	// nada
       
    39     	}
       
    40     void Start();
       
    41     void ConstructL();
       
    42 private:
       
    43     static const TUint KTimerServerShutdownDelay=3000000;
       
    44     void RunL();
       
    45     };
       
    46 
       
    47 NONSHARABLE_CLASS(CTimerServer) : public CServer2
       
    48     {
       
    49 public:
       
    50 	// We want the transfers to be done on a priority. Hence the EPriorityHigh
       
    51 	CTimerServer() : CServer2(EPriorityHigh,ESharableSessions)
       
    52     	{
       
    53     	// nada
       
    54     	}
       
    55     	
       
    56     ~CTimerServer();
       
    57     static CTimerServer* NewLC();
       
    58     
       
    59     TInt AddToScheduler();
       
    60     void RemoveFromScheduler();
       
    61     TInt RemoveInternal(const TInt);
       
    62     TInt SetTimer(const TInt);
       
    63 	void StartServer();
       
    64 	static TInt NewTimerServerL();
       
    65     void AddSession();
       
    66     void DropSession();
       
    67     
       
    68     CActiveScheduler* iOldScheduler;
       
    69     
       
    70 private:
       
    71     void ConstructL();
       
    72     CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
       
    73 private:
       
    74     TInt iSessionCount;
       
    75     CShutdown* iShutdown;
       
    76     };
       
    77 
       
    78 NONSHARABLE_CLASS(CTimerServerSession) : public CSession2
       
    79     {
       
    80 public:
       
    81     void CreateL();
       
    82 private:
       
    83     ~CTimerServerSession();
       
    84     CTimerServer& Server();
       
    85     void ServiceL(const RMessage2& aMessage);
       
    86     void ServiceError(const RMessage2& aMessage, TInt aError);
       
    87 	};
       
    88     
       
    89 #endif //__TIMERSERVER_H__