scope_guard.hpp
Go to the documentation of this file.
00001 
00017 #ifndef THREADPOOL_DETAIL_SCOPE_GUARD_HPP_INCLUDED
00018 #define THREADPOOL_DETAIL_SCOPE_GUARD_HPP_INCLUDED
00019 
00020 
00021 
00022 #include <boost/function.hpp>
00023 
00024 
00025 namespace boost { namespace threadpool { namespace detail 
00026 {
00027 
00028 // TODO documentation
00029 class scope_guard
00030 : private boost::noncopyable
00031 {
00032         function0<void> const m_function;
00033         bool                  m_is_active;
00034 
00035 public:
00036         scope_guard(function0<void> const & call_on_exit)
00037         : m_function(call_on_exit)
00038         , m_is_active(true)
00039         {
00040         }
00041 
00042         ~scope_guard()
00043         {
00044                 if(m_is_active && m_function)
00045                 {
00046                         m_function();
00047                 }
00048         }
00049 
00050         void disable()
00051         {
00052                 m_is_active = false;
00053         }
00054 };
00055 
00056 
00057 
00058 
00059 
00060 
00061 } } } // namespace boost::threadpool::detail
00062 
00063 #endif // THREADPOOL_DETAIL_SCOPE_GUARD_HPP_INCLUDED
00064 
00065 


or_libs
Author(s): raphael
autogenerated on Mon Oct 6 2014 02:53:18