Rev | Line | |
---|
[857] | 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
|
---|
Note: See
TracBrowser
for help on using the repository browser.