debugsrv/runmodedebug/rmdriver/inc/d_debug_agent.inl
branchRCL_3
changeset 20 ca8a1b6995f6
equal deleted inserted replaced
19:07b41fa8d1dd 20:ca8a1b6995f6
       
     1 // Copyright (c) 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 the License "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 // Inline methods for debug agent class
       
    15 //
       
    16 
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21  @released
       
    22 */
       
    23 
       
    24 #ifndef D_DEBUG_AGENT_INL
       
    25 #define D_DEBUG_AGENT_INL
       
    26 
       
    27 
       
    28 /**
       
    29  Checks whether the event queue is empty
       
    30 */
       
    31 inline TBool DDebugAgent::BufferEmpty() const
       
    32 	{
       
    33 	return (NumberOfEmptySlots() == KNumberOfEventsToQueue);
       
    34 	}
       
    35 
       
    36 /**
       
    37  Checks whether the event queue is full
       
    38 */
       
    39 inline TBool DDebugAgent::BufferFull() const
       
    40 	{
       
    41 	return (NumberOfEmptySlots() == 0);
       
    42 	}
       
    43 
       
    44 /**
       
    45  Checks whether there is room in the event queue to store an event
       
    46 */
       
    47 inline TBool DDebugAgent::BufferCanStoreEvent() const
       
    48 	{
       
    49 	return (NumberOfEmptySlots() > 0);
       
    50 	}
       
    51 
       
    52 /**
       
    53  This looks to see if the buffer is close to being full and should only
       
    54  accept higher priority debug events (user trace is the only low priority event) 
       
    55 */
       
    56 inline TBool DDebugAgent::BufferAtCriticalLevel() const
       
    57 	{
       
    58 	return (NumberOfEmptySlots() < KNumberOfEventsToQueue - KCriticalBufferSize);
       
    59 	}
       
    60 
       
    61 /**
       
    62  Increments Head position, wrapping at KNumberOfEventsToQueue if necessary
       
    63 */
       
    64 inline void DDebugAgent::IncrementHeadPosition(void)
       
    65 	{
       
    66 	iHead = (iHead + 1) % KNumberOfEventsToQueue;
       
    67 
       
    68 	iFreeSlots--;
       
    69 	}
       
    70 
       
    71 /**
       
    72  Increments Tail position, wrapping at KNumberOfEventsToQueue if necessary
       
    73 */
       
    74 inline void DDebugAgent::IncrementTailPosition(void)
       
    75 	{
       
    76 	iTail = (iTail + 1) % KNumberOfEventsToQueue;
       
    77 
       
    78 	iFreeSlots++;
       
    79 }
       
    80 
       
    81 /**
       
    82  Returns the number of free slots in the event queue
       
    83 */
       
    84 inline TInt DDebugAgent::NumberOfEmptySlots() const
       
    85 	{
       
    86 	return iFreeSlots;
       
    87 	}
       
    88 
       
    89 /**
       
    90  Lock access to this agent's event queue
       
    91 */
       
    92 inline void DDebugAgent::LockEventQueue(void)
       
    93 	{
       
    94 	NKern::ThreadEnterCS(); // Waiting on a semaphore is broken but this makes things marginally better.
       
    95 	// Anyone changing this, bear in mind the CS is also needed for some of the DebugUtils::OpenThreadHandle calls
       
    96 	Kern::SemaphoreWait(*iEventQueueLock);
       
    97 	}
       
    98 
       
    99 /**
       
   100  Release the lock on this agent's event queue
       
   101 */
       
   102 inline void DDebugAgent::UnlockEventQueue(void)
       
   103 	{
       
   104 	Kern::SemaphoreSignal(*iEventQueueLock);
       
   105 	NKern::ThreadLeaveCS();
       
   106 	}
       
   107 
       
   108 
       
   109 #endif	// D_DEBUG_AGENT_INL