📄 umc_mutex.h
字号:
/*//// INTEL CORPORATION PROPRIETARY INFORMATION// This software is supplied under the terms of a license agreement or// nondisclosure agreement with Intel Corporation and may not be copied// or disclosed except in accordance with the terms of that agreement.// Copyright(c) 2003-2005 Intel Corporation. All Rights Reserved.//*/#ifndef __UMC_MUTEX_H#define __UMC_MUTEX_H#include "vm_debug.h"#include "vm_mutex.h"#include "umc_structures.h"namespace UMC{class Mutex{public: // Default constructor Mutex(void); // Destructor virtual ~Mutex(void); // Initialize mutex Status Init(void); // Get ownership of mutex void Lock(void); // Release ownership of mutex void Unlock(void); // Try to get ownership of mutex Status TryLock(void); // Get ownership of initialized mutex void LockIfInitialized(void); // Release ownership of initialized mutex void UnlockIfInitialized(void); // Is mutex inited bool IsInited(void);protected: vm_mutex m_handle; // (vm_mutex) handle to system mutex};inlinevoid Mutex::Lock(void){ Status umcRes = UMC_OK; if (!vm_mutex_is_valid(&m_handle)) umcRes = Init(); if ((UMC_OK == umcRes) && (VM_OK != vm_mutex_lock(&m_handle))) assert(false);} // void Mutex::Lock(void)inlinevoid Mutex::Unlock(void){ Status umcRes = UMC_OK; if (!vm_mutex_is_valid(&m_handle)) umcRes = Init(); else if (VM_OK != vm_mutex_unlock(&m_handle)) assert(false);} // void Mutex::Unlock(void)inlineStatus Mutex::TryLock(void){ Status umcRes = UMC_OK; if (!vm_mutex_is_valid(&m_handle)) umcRes = Init(); if (UMC_OK == umcRes) umcRes = vm_mutex_try_lock(&m_handle); return umcRes;} // Status Mutex::TryLock(void)inlinevoid Mutex::LockIfInitialized(void){ if (vm_mutex_is_valid(&m_handle) && (VM_OK != vm_mutex_lock(&m_handle))) assert(false);} // void Mutex::LockIfInitialized(void)inlinevoid Mutex::UnlockIfInitialized(void){ if (vm_mutex_is_valid(&m_handle) && (VM_OK != vm_mutex_unlock(&m_handle))) assert(false);} // void Mutex::UnlockIfInitialized(void)inlinebool Mutex::IsInited(void){ return (0 != vm_mutex_is_valid(&m_handle));} // bool Mutex::IsInited(void)} // namespace UMC#endif // __UMC_MUTEX_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -