os/ossrv/ossrv_pub/boost_apis/boost/pool/detail/guard.hpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (C) 2000 Stephen Cleary
     2 //
     3 // Distributed under the Boost Software License, Version 1.0. (See
     4 // accompanying file LICENSE_1_0.txt or copy at
     5 // http://www.boost.org/LICENSE_1_0.txt)
     6 //
     7 // See http://www.boost.org for updates, documentation, and revision history.
     8 
     9 #ifndef BOOST_POOL_GUARD_HPP
    10 #define BOOST_POOL_GUARD_HPP
    11 
    12 // Extremely Light-Weight guard glass
    13 
    14 namespace boost {
    15 
    16 namespace details {
    17 namespace pool {
    18 
    19 template <typename Mutex>
    20 class guard
    21 {
    22   private:
    23     Mutex & mtx;
    24 
    25     guard(const guard &);
    26     void operator=(const guard &);
    27 
    28   public:
    29     explicit guard(Mutex & nmtx)
    30     :mtx(nmtx) { mtx.lock(); }
    31 
    32     ~guard() { mtx.unlock(); }
    33 };
    34 
    35 } // namespace pool
    36 } // namespace details
    37 
    38 } // namespace boost
    39 
    40 #endif