diff options
| author | karlf <[email protected]> | 2016-08-11 13:28:13 -0700 |
|---|---|---|
| committer | karlf <[email protected]> | 2016-08-11 13:28:13 -0700 |
| commit | 96eb96dfb613e4c745db6bd1f53a92fe7e2290fc (patch) | |
| tree | ad5f3ede5cbcd6b598677ce41bcf8318471bdd92 /AVStream/avscamera/sys/Mutex.cpp | |
| parent | 687b274aa38fd05c8c26e3068932121876d7f745 (diff) | |
Updated for "Windows 10 Anniversary Update" (Version 1607)
Diffstat (limited to 'AVStream/avscamera/sys/Mutex.cpp')
| -rw-r--r-- | AVStream/avscamera/sys/Mutex.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/AVStream/avscamera/sys/Mutex.cpp b/AVStream/avscamera/sys/Mutex.cpp new file mode 100644 index 00000000..1dd3d88c --- /dev/null +++ b/AVStream/avscamera/sys/Mutex.cpp @@ -0,0 +1,70 @@ +/************************************************************************** + + A/V Stream Camera Sample + + Copyright (c) 2013, Microsoft Corporation. + + File: + + Mutex.cpp + + Abstract: + + This file provides the implementation of KMutex and KScopedMutex. + + KMutex provides a wrapper around a KMUTEX object. KScopedMutex is + provided as a helper class to ensure all exits release the lock. + + History: + + created 7/16/2013 + +**************************************************************************/ + +#include "Common.h" + +// +// Dummy dtor. Required because the dtor is virtual. +// +KMutex::~KMutex() +{} + +// +// Preferred lock method. +// +_IRQL_requires_min_(PASSIVE_LEVEL) +_When_((Timeout==NULL || Timeout->QuadPart!=0), _IRQL_requires_max_(APC_LEVEL)) +_When_((Timeout!=NULL &&Timeout->QuadPart==0), _IRQL_requires_max_(DISPATCH_LEVEL)) +NTSTATUS +KMutex::Lock( + _In_opt_ PLARGE_INTEGER Timeout +) +{ + //DBG_ENTER(": Thread Owner = %p", m_Lock.OwnerThread); + + NTSTATUS status = + KeWaitForSingleObject( + &m_Lock, + Executive, + KernelMode, + FALSE, + Timeout ); + + //DBG_LEAVE(": Status = %d Thread Owner = %p", status, m_Lock.OwnerThread); + + return status; +} + +// +// Preferred unlock method. +// +_IRQL_requires_max_(DISPATCH_LEVEL) +void +KMutex::Unlock() +{ + //DBG_ENTER(": Thread Owner = %p", m_Lock.OwnerThread); + + KeReleaseMutex( &m_Lock, FALSE ); + + //DBG_LEAVE(": Thread Owner = %p", m_Lock.OwnerThread); +} |
