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