00001 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 00002 * 00003 * $Id: vtkSimpleScopeLocker.h,v 1.3 2004/08/10 07:37:21 xpxqx Exp $ 00004 * 00005 * Copyright (c) 2004 Sean McInerney 00006 * All rights reserved. 00007 * 00008 * See Copyright.txt or http://vtkextensions.sourceforge.net/Copyright.html 00009 * for details. 00010 * 00011 * This software is distributed WITHOUT ANY WARRANTY; without even 00012 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 * PURPOSE. See the above copyright notice for more information. 00014 * 00015 */ 00016 #ifndef VTK_SIMPLE_SCOPE_LOCKER_H_ 00017 # define VTK_SIMPLE_SCOPE_LOCKER_H_ 00018 // vtkExtensions 00019 # include "vtkExtensionsCommonConfigure.h" // vtkExtensions configuration 00020 // VTK Common 00021 # include "vtkCriticalSection.h" 00022 00023 # if defined(VTK_EXTENSIONS_OBJECT_LEVEL_LOCKABLE) 00024 # define VTK_SIMPLE_SCOPE_LOCKER (name_, mutex_) \ 00025 vtkSimpleScopeLocker name_(mutex_) 00026 # else 00027 # define VTK_SIMPLE_SCOPE_LOCKER (name_, mutex_) 00028 # endif /* !VTK_EXTENSIONS_OBJECT_LEVEL_LOCKABLE */ 00029 00030 VTK_EXTENSIONS_NAMESPACE_BEGIN 00031 00039 class VTK_EXTENSIONS_COMMON_EXPORT vtkSimpleScopeLocker 00040 { 00041 vtkSimpleCriticalSection& m_; 00042 00043 public: 00044 vtkSimpleScopeLocker (vtkSimpleCriticalSection& a) : m_(a) { m_.Lock(); } 00045 ~vtkSimpleScopeLocker() { m_.Unlock(); } 00046 }; 00047 00048 VTK_EXTENSIONS_NAMESPACE_END 00049 00050 #endif /* VTK_SIMPLE_SCOPE_LOCKER_H_ */ 00051 /* 00052 * End of: $Id: vtkSimpleScopeLocker.h,v 1.3 2004/08/10 07:37:21 xpxqx Exp $. 00053 * 00054 */