ScopedRWLock.cpp
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 //----------------------------------------------------------------------
00009 //----------------------------------------------------------------------
00010 #include "icl_core_thread/ScopedRWLock.h"
00011 
00012 #include "icl_core_thread/RWLock.h"
00013 
00014 namespace icl_core {
00015 namespace thread {
00016 
00017 ScopedRWLock::ScopedRWLock(RWLock& lock, LockMode lock_mode, bool force)
00018   : m_lock(lock), m_is_locked(false)
00019 {
00020   if (lock_mode == eLM_READ_LOCK)
00021   {
00022     do { m_is_locked = m_lock.readLock(); } while (force && !m_is_locked);
00023   }
00024   else
00025   {
00026     do { m_is_locked = m_lock.writeLock(); } while (force && !m_is_locked);
00027   }
00028 }
00029 
00030 ScopedRWLock::~ScopedRWLock()
00031 {
00032   if (isLocked())
00033   {
00034     m_lock.unlock();
00035   }
00036 }
00037 
00039 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
00040 
00044 bool ScopedRWLock::IsLocked() const
00045 {
00046   return isLocked();
00047 }
00048 
00049 #endif
00050 
00051 
00052 }
00053 }


schunk_svh_driver
Author(s): Georg Heppner
autogenerated on Fri Aug 28 2015 12:59:19