os/ossrv/genericopenlibs/posixrealtimeextensions/inc/timerhandler.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2008-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 // timer handler header file
    15 // 
    16 //
    17 
    18 
    19 #ifndef __TIMERHANDLER__H
    20 #define __TIMERHANDLER__H
    21 
    22 #include "timer.h"
    23 #include "timerserver.h"
    24 #include "timerclient.h"
    25 
    26 #define MAXTIMERLIMIT 512
    27 #define DELAYTIMER_MAX 32
    28 
    29 class CTimerReqHandler: public CBase
    30 {
    31 public:	
    32 	friend class CTimerServer;
    33 	friend class CLibRtTimer;
    34 	TInt CreateTimer(TInt& aTimerId, struct sigevent *aSig);
    35 	TInt RemoveTimer(const TInt& aTimerId);	
    36 	TInt Time(const TInt& aTimerId, struct itimerspec *aTime);
    37 	TInt SetTime(const TInt& aTimerId, TInt aFlag, const struct itimerspec *aIpTime,
    38 			 struct itimerspec *aOpTime);	
    39 	TInt OverrunCount(const TInt& aTimerId, TInt& aOverrunCount);
    40 	TInt TimerRequestHandler();
    41 	
    42 	CTimerReqHandler();	 						   							   
    43 	~CTimerReqHandler();
    44 	RTimerSession session;
    45 	inline void SetServerHandle(RServer2 aServer)
    46 		{
    47 		iServer = aServer;
    48 		}
    49 	RServer2 iServer;
    50 	inline void ResetClientFlag()
    51 	    {
    52 	    session.ResetConnectionFlag();
    53 	    }
    54 	inline void ResetServerFlag()
    55 		{
    56 		iServConnectLock.Wait();
    57 		iIsServStarted = EFalse;
    58 		iServConnectLock.Signal();
    59 		}
    60 private:
    61 	TInt Connect();
    62 	CRtTimer* FindTimer(const TInt& aTimerId);
    63 	TInt StartTimerServer();
    64 
    65 	const static TInt KTimersGran = 4;			 						   
    66 	CArrayPtrSeg<CRtTimer> iTimers;
    67 	RMutex iTimersLock;	
    68 	
    69 	RThread	iServ; //timer server thread
    70 
    71 	TBool 	iIsServStarted;
    72 	RMutex 	iServConnectLock;
    73 	RSemaphore iTimerSemaphore;
    74 };
    75 
    76 CTimerReqHandler* getTimerHandler();
    77 
    78 #endif //__TIMERHANDLER__H
    79