ScopedSpinLock.h
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 
00003 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00004 // This file is part of FZIs ic_workspace.
00005 //
00006 // This program is free software licensed under the LGPL
00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
00008 // You can find a copy of this license in LICENSE folder in the top
00009 // directory of the source code.
00010 //
00011 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
00012 //
00013 // -- END LICENSE BLOCK ------------------------------------------------
00014 
00015 //----------------------------------------------------------------------
00022 //----------------------------------------------------------------------
00023 #ifndef ICL_CORE_THREAD_SCOPED_SPIN_LOCK_H_INCLUDED
00024 #define ICL_CORE_THREAD_SCOPED_SPIN_LOCK_H_INCLUDED
00025 
00026 #include <icl_core_thread/SpinLock.h>
00027 
00028 namespace icl_core {
00029 namespace thread {
00030 
00031 class ScopedSpinLock : protected virtual icl_core::Noncopyable
00032 {
00033 public:
00037   explicit ScopedSpinLock(SpinLock& spinlock)
00038     : m_spinlock(spinlock)
00039   {
00040     m_spinlock.lock();
00041   }
00042 
00044   ~ScopedSpinLock()
00045   {
00046     m_spinlock.unlock();
00047   }
00048 
00052   bool isLocked() const { return true; }
00053 
00055   operator bool () const { return isLocked(); }
00056 
00057 private:
00058   SpinLock& m_spinlock;
00059 };
00060 
00061 }
00062 }
00063 
00064 #endif


fzi_icl_core
Author(s):
autogenerated on Tue Aug 8 2017 02:28:03