Mark3 Realtime Kernel
lockguard.cpp
Go to the documentation of this file.
1 /*===========================================================================
2  _____ _____ _____ _____
3  ___| _|__ __|_ |__ __|__ |__ __| __ |__ ______
4 | \ / | || \ || | || |/ / ||___ |
5 | \/ | || \ || \ || \ ||___ |
6 |__/\__/|__|_||__|\__\ __||__|\__\ __||__|\__\ __||______|
7  |_____| |_____| |_____| |_____|
8 
9 --[Mark3 Realtime Platform]--------------------------------------------------
10 
11 Copyright (c) 2018 m0slevin, all rights reserved.
12 See license.txt for more information
13 ===========================================================================*/
20 #include "mark3.h"
21 
22 namespace Mark3
23 {
24 //---------------------------------------------------------------------------
26  : m_bIsAcquired { true }
27  , m_pclMutex { pclMutex_ }
28 {
29  KERNEL_ASSERT(nullptr != m_pclMutex);
30  m_pclMutex->Claim();
31 }
32 
33 //---------------------------------------------------------------------------
34 LockGuard::LockGuard(Mutex* pclMutex_, uint32_t u32TimeoutMs_)
35  : m_pclMutex { pclMutex_ }
36 {
37  KERNEL_ASSERT(nullptr != pclMutex_);
38  m_bIsAcquired = m_pclMutex->Claim(u32TimeoutMs_);
39 }
40 
41 //---------------------------------------------------------------------------
43 {
44  if (m_bIsAcquired) {
46  }
47 }
48 
49 } // namespace Mark3
Mutex * m_pclMutex
Definition: lockguard.h:58
LockGuard(Mutex *pclMutex)
Definition: lockguard.cpp:25
void Release()
Release Release the mutex. When the mutex is released, another object can enter the mutex-protected r...
Definition: mutex.cpp:197
#define KERNEL_ASSERT(x)
Definition: kerneldebug.h:36
void Claim()
Claim Claim the mutex. When the mutex is claimed, no other thread can claim a region protected by the...
Definition: mutex.cpp:185
Definition: atomic.cpp:23
The Mutex Class. Class providing Mutual-exclusion locks, based on BlockingObject. ...
Definition: mutex.h:63
Single include file given to users of the Mark3 Kernel API.
bool m_bIsAcquired
Definition: lockguard.h:57