eapol/eapol_framework/eapol_common/am/include/abs_eap_am_mutex.h
changeset 0 c8830336c852
child 2 1c7bc153c08e
equal deleted inserted replaced
-1:000000000000 0:c8830336c852
       
     1 /*
       
     2 * Copyright (c) 2001-2006 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 the License "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:  EAP and WLAN authentication protocols.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #if !defined( _ABS_EAP_AM_MUTEX_H_ )
       
    22 #define _ABS_EAP_AM_MUTEX_H_
       
    23 
       
    24 #include "eap_am_types.h"
       
    25 #include "eap_variable_data.h"
       
    26 #include "eap_am_export.h"
       
    27 
       
    28 class eap_am_mutex_reference_c;
       
    29 
       
    30 // ---------------------------------------------
       
    31 
       
    32 /// This class is interface to mutex.
       
    33 class EAP_EXPORT abs_eap_am_mutex_c
       
    34 {
       
    35 private:
       
    36 
       
    37 public:
       
    38 
       
    39 	EAP_FUNC_IMPORT virtual ~abs_eap_am_mutex_c();
       
    40 
       
    41 	EAP_FUNC_IMPORT abs_eap_am_mutex_c();
       
    42 
       
    43 	// - - - - - - - - - - - - - - - - - - - - - - - -
       
    44 
       
    45 	/**
       
    46 	 * This function enters the mutex. Thread will block until the mutex is released
       
    47 	 * by other owner of the mutex.
       
    48 	 */
       
    49 	EAP_FUNC_IMPORT virtual eap_status_e mutex_enter() = 0;
       
    50 
       
    51 	/**
       
    52 	 * This function leaves the mutex. Other blocking thread will continue execution.
       
    53 	 */
       
    54 	EAP_FUNC_IMPORT virtual eap_status_e mutex_leave(abs_eap_am_tools_c * const m_am_tools) = 0;
       
    55 
       
    56 	/**
       
    57 	 * The mutex handle must be dublicated in Symbian operating system for each thread.
       
    58 	 */
       
    59 	EAP_FUNC_IMPORT virtual abs_eap_am_mutex_c * dublicate_mutex() = 0;
       
    60 
       
    61 	/**
       
    62 	 * This function returns the flag that indicates whether the mutex is reserved. 
       
    63 	 * This is used in debug asserts. Those will check the mutex is really reserved when critical code is entered.
       
    64 	 */
       
    65 	EAP_FUNC_IMPORT virtual bool get_is_reserved() const = 0;
       
    66 
       
    67 	/**
       
    68 	 * Returns the validity of the mutex.
       
    69 	 */
       
    70 	EAP_FUNC_IMPORT virtual bool get_is_valid() const = 0;
       
    71 
       
    72 #if defined(USE_EAPOL_MUTEX_SEMAPHORE_TRACES)
       
    73 	EAP_FUNC_IMPORT virtual eap_am_mutex_reference_c * get_reference() const = 0;
       
    74 	EAP_FUNC_IMPORT virtual void set_am_tools(abs_eap_am_tools_c * const tools) = 0;
       
    75 #endif //#if defined(USE_EAPOL_MUTEX_SEMAPHORE_TRACES)
       
    76 
       
    77 	// - - - - - - - - - - - - - - - - - - - - - - - -
       
    78 
       
    79 };
       
    80 
       
    81 // ---------------------------------------------
       
    82 
       
    83 /// This class defines a reference counter of a mutex.
       
    84 class EAP_EXPORT eap_am_mutex_reference_c
       
    85 {
       
    86 
       
    87 private:
       
    88 
       
    89 	/// This is the reference count to the mutex.
       
    90 	u32_t m_reference_count;
       
    91 
       
    92 	/// This flag indicates whether the mutex is reserved. 
       
    93 	/// This is used in debug asserts. Those will check the mutex is really reserved when critical code is entered.
       
    94 	bool m_is_reserved;
       
    95 
       
    96 	// On purpose unimplemented constructors.
       
    97 	eap_am_mutex_reference_c(eap_am_mutex_reference_c &source);
       
    98 	const eap_am_mutex_reference_c & operator=(const eap_am_mutex_reference_c& source);
       
    99 
       
   100 public:
       
   101 
       
   102 	EAP_FUNC_IMPORT virtual ~eap_am_mutex_reference_c();
       
   103 
       
   104 	EAP_FUNC_IMPORT eap_am_mutex_reference_c();
       
   105 
       
   106 	/**
       
   107 	 * This function adds one reference to the mutex. 
       
   108 	 */
       
   109 	EAP_FUNC_IMPORT void add_reference();
       
   110 
       
   111 	/**
       
   112 	 * This function removes one reference to the mutex. 
       
   113 	 */
       
   114 	EAP_FUNC_IMPORT void remove_reference();
       
   115 
       
   116 	/**
       
   117 	 * This function returns the reference count of the mutex. 
       
   118 	 */
       
   119 	EAP_FUNC_IMPORT u32_t get_reference_count();
       
   120 
       
   121 	/**
       
   122 	 * This function sets the flag that indicates whether the mutex is reserved. 
       
   123 	 */
       
   124 	EAP_FUNC_IMPORT void set_is_reserved(const bool is_reserved);
       
   125 
       
   126 	/**
       
   127 	 * This function returns the flag that indicates whether the mutex is reserved. 
       
   128 	 * This is used in debug asserts. Those will check the mutex is really reserved when critical code is entered.
       
   129 	 */
       
   130 	EAP_FUNC_IMPORT bool get_is_reserved();
       
   131 };
       
   132 
       
   133 // ---------------------------------------------
       
   134 
       
   135 /// This class is base of the mutex.
       
   136 class EAP_EXPORT eap_am_mutex_base_c
       
   137 {
       
   138 private:
       
   139 
       
   140 	eap_am_mutex_reference_c * m_reference;
       
   141 
       
   142 	bool m_is_valid;
       
   143 
       
   144 	// On purpose unimplemented constructors.
       
   145 	eap_am_mutex_base_c(eap_am_mutex_base_c &source);
       
   146 	const eap_am_mutex_base_c & operator=(const eap_am_mutex_base_c& source);
       
   147 
       
   148 public:
       
   149 
       
   150 	EAP_FUNC_IMPORT virtual ~eap_am_mutex_base_c();
       
   151 
       
   152 	EAP_FUNC_IMPORT eap_am_mutex_base_c();
       
   153 
       
   154 	EAP_FUNC_IMPORT eap_am_mutex_base_c(const eap_am_mutex_base_c * const owner);
       
   155 
       
   156 	/**
       
   157 	 * This function returns pointer to the reference counter object of the mutex.
       
   158 	 */
       
   159 	EAP_FUNC_IMPORT eap_am_mutex_reference_c * get_reference() const;
       
   160 
       
   161 	// - - - - - - - - - - - - - - - - - - - - - - - -
       
   162 
       
   163 	/**
       
   164 	 * This function returns the flag that indicates whether the mutex is reserved. 
       
   165 	 * This is used in debug asserts. Those will check the mutex is really reserved when critical code is entered.
       
   166 	 */
       
   167 	EAP_FUNC_IMPORT bool get_is_reserved() const;
       
   168 
       
   169 	/**
       
   170 	 * Returns the validity of the mutex.
       
   171 	 */
       
   172 	EAP_FUNC_IMPORT bool get_is_valid() const;
       
   173 
       
   174 	// - - - - - - - - - - - - - - - - - - - - - - - -
       
   175 
       
   176 };
       
   177 
       
   178 // ---------------------------------------------
       
   179 
       
   180 #endif //#if !defined( _ABS_EAP_AM_MUTEX_H_ )
       
   181 
       
   182 
       
   183 
       
   184 // End.