diff options
author | John Sonnenschein <johns@joyent.com> | 2012-05-17 18:26:57 +0000 |
---|---|---|
committer | John Sonnenschein <johns@joyent.com> | 2012-05-17 18:26:57 +0000 |
commit | 04b244dd661c24b510ac22936decfc0972d202d3 (patch) | |
tree | 3ebfef98afc303fddf3415d6fba64e8682f495e8 /usr/src/lib/libkmsagent/common/AutoMutex.h | |
parent | eac250589e41f1b705e1b7427b02b3379aac9f9e (diff) | |
parent | a69187741b83640a90dd8586195456dd50c016a8 (diff) | |
download | illumos-joyent-20120517.tar.gz |
Merge git.joyent.com:illumos-joyent20120517
Diffstat (limited to 'usr/src/lib/libkmsagent/common/AutoMutex.h')
-rw-r--r-- | usr/src/lib/libkmsagent/common/AutoMutex.h | 157 |
1 files changed, 0 insertions, 157 deletions
diff --git a/usr/src/lib/libkmsagent/common/AutoMutex.h b/usr/src/lib/libkmsagent/common/AutoMutex.h deleted file mode 100644 index 31943e8559..0000000000 --- a/usr/src/lib/libkmsagent/common/AutoMutex.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - */ - -/*------------------------------------------------------------------------------ - * Module : AutoMutex.h - -----------------------------------------------------------------------------*/ - -#ifndef AutoMutex_h -#define AutoMutex_h - -#include "SYSCommon.h" - -class CAutoMutex -{ -public: - - /*--------------------------------------------------------------------------- - * Constructor: - * Locks the given mutex handle. - * - * Input - * ----- - * i_hMutex Mutex handle - * - * Output - * ------ - * (none) - * - * Return value (none) - * - *--------------------------------------------------------------------------*/ - - CAutoMutex( K_MUTEX_HANDLE i_hMutex ) - : m_hMutex( 0 ), - m_bLocked( false ) - { - if ( i_hMutex ) - { - Lock( i_hMutex ); - } - } - - - /*--------------------------------------------------------------------------- - * Destructor: - * Unlocks this mutex. - * - * Input - * ----- - * (none) - * - * Output - * ------ - * (none) - * - * Return value (none) - * - *--------------------------------------------------------------------------*/ - - virtual ~CAutoMutex() - { - if ( m_bLocked ) - { - Unlock(); - } - } - - /*--------------------------------------------------------------------------- - * Function: Lock - * - * Description: - * Locks this mutex handle. If i_hMutex is null, the handle passed to the - * constructor will be used. Fatals if there is no valid handle. - * - * Input - * ----- - * i_hMutex Mutex handle to lock - * - * Output - * ------ - * (none) - * - * Return value (none) - * - *--------------------------------------------------------------------------*/ - - void Lock( K_MUTEX_HANDLE i_hMutex = 0 ) - { - FATAL_ASSERT( !m_bLocked ); - - if ( i_hMutex ) - { - m_hMutex = i_hMutex; - } - - FATAL_ASSERT( m_hMutex ); - K_LockMutex( m_hMutex ); - m_bLocked = true; - } - - - /*--------------------------------------------------------------------------- - * Function: Unlock - * - * Description: - * Unlocks the mutex handle passed to the constructor or to a previous - * Lock call. Fatals if the mutex is not locked. - * - * Input - * ----- - * (none) - * - * Output - * ------ - * (none) - * - * Return value (none) - * - *--------------------------------------------------------------------------*/ - - void Unlock() - { - FATAL_ASSERT( m_bLocked ); - FATAL_ASSERT( m_hMutex ); - K_UnlockMutex( m_hMutex ); - m_bLocked = false; - } - -private: - K_MUTEX_HANDLE m_hMutex; - bool m_bLocked; -}; - - -#endif // AutoMutex_h |