Version

menu_open
Target Platform(s):

include/AK/Tools/Win32/AkLock.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 The content of this file includes portions of the AUDIOKINETIC Wwise Technology
00003 released in source code form as part of the SDK installer package.
00004 
00005 Commercial License Usage
00006 
00007 Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
00008 may use this file in accordance with the end user license agreement provided 
00009 with the software or, alternatively, in accordance with the terms contained in a
00010 written agreement between you and Audiokinetic Inc.
00011 
00012 Apache License Usage
00013 
00014 Alternatively, this file may be used under the Apache License, Version 2.0 (the 
00015 "Apache License"); you may not use this file except in compliance with the 
00016 Apache License. You may obtain a copy of the Apache License at 
00017 http://www.apache.org/licenses/LICENSE-2.0.
00018 
00019 Unless required by applicable law or agreed to in writing, software distributed
00020 under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
00021 OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
00022 the specific language governing permissions and limitations under the License.
00023 
00024   Version: <VERSION>  Build: <BUILDNUMBER>
00025   Copyright (c) <COPYRIGHTYEAR> Audiokinetic Inc.
00026 *******************************************************************************/
00027 
00028 #ifndef _AKLOCK_H_
00029 #define _AKLOCK_H_
00030 
00031 #include <AK/SoundEngine/Common/AkTypes.h>
00032 #include <windows.h>    //For CRITICAL_SECTION
00033 
00034 //-----------------------------------------------------------------------------
00035 // CAkLock class
00036 //-----------------------------------------------------------------------------
00037 class CAkLock
00038 {
00039 public:
00041     CAkLock() 
00042     {
00043 #ifdef AK_USE_METRO_API
00044         ::InitializeCriticalSectionEx( &m_csLock, 0, 0 );
00045 #else
00046         ::InitializeCriticalSection( &m_csLock );
00047 #endif
00048     }
00049 
00051     ~CAkLock()
00052     {
00053         ::DeleteCriticalSection( &m_csLock );
00054     }
00055 
00057     inline AKRESULT Lock( void )
00058     {
00059         ::EnterCriticalSection( &m_csLock );
00060         return AK_Success;
00061     }
00062 
00064     inline AKRESULT Unlock( void )
00065     {
00066         ::LeaveCriticalSection( &m_csLock );
00067         return AK_Success;
00068     }
00069 
00070 /*  // Returns AK_Success if lock aquired, AK_Fail otherwise.
00071     inline AKRESULT Trylock( void )
00072     {
00073         if ( ::TryEnterCriticalSection( &m_csLock ) )
00074             return AK_Success;
00075         return AK_Fail;
00076     } */
00077 
00078 private:
00079     CRITICAL_SECTION  m_csLock; 
00080 };
00081 
00082 #endif // _AKLOCK_H_

Was this page helpful?

Need Support?

Questions? Problems? Need more info? Contact us, and we can help!

Visit our Support page

Tell us about your project. We're here to help.

Register your project and we'll help you get started with no strings attached!

Get started with Wwise