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 //---------------------------------------------------------------------- 00028 //---------------------------------------------------------------------- 00029 #ifndef ICL_CORE_LOGGING_SCOPED_SEMAPHORE_H_INCLUDED 00030 #define ICL_CORE_LOGGING_SCOPED_SEMAPHORE_H_INCLUDED 00031 00032 #include <icl_core/BaseTypes.h> 00033 #include <icl_core/Noncopyable.h> 00034 #include "icl_core_logging/ImportExport.h" 00035 00036 #ifdef _IC_BUILDER_DEPRECATED_STYLE_ 00037 # include "icl_core/Deprecate.h" 00038 #endif 00039 00040 namespace icl_core { 00041 namespace logging { 00042 00043 class Semaphore; 00044 00050 class ICL_CORE_LOGGING_IMPORT_EXPORT ScopedSemaphore : protected virtual icl_core::Noncopyable 00051 { 00052 public: 00054 explicit ScopedSemaphore(Semaphore& semaphore); 00055 00057 ~ScopedSemaphore(); 00058 00060 bool isDecremented() const { return m_is_decremented; } 00061 00063 operator bool () const { return isDecremented(); } 00064 00066 #ifdef _IC_BUILDER_DEPRECATED_STYLE_ 00067 00071 ICL_CORE_VC_DEPRECATE_STYLE bool IsDecremented() const ICL_CORE_GCC_DEPRECATE_STYLE; 00072 00073 #endif 00074 00075 00076 private: 00077 Semaphore& m_semaphore; 00078 bool m_is_decremented; 00079 }; 00080 00081 } 00082 } 00083 00084 #endif