/usr/include/boost/atomic/detail/lockpool.hpp is in libboost1.54-dev 1.54.0-4ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | #ifndef BOOST_ATOMIC_DETAIL_LOCKPOOL_HPP
#define BOOST_ATOMIC_DETAIL_LOCKPOOL_HPP
// Copyright (c) 2011 Helge Bahmann
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/atomic/detail/config.hpp>
#ifndef BOOST_ATOMIC_FLAG_LOCK_FREE
#include <boost/thread/mutex.hpp>
#endif
#ifdef BOOST_ATOMIC_HAS_PRAGMA_ONCE
#pragma once
#endif
namespace boost {
namespace atomics {
namespace detail {
#ifndef BOOST_ATOMIC_FLAG_LOCK_FREE
class lockpool
{
public:
typedef mutex lock_type;
class scoped_lock
{
private:
lock_type& mtx_;
scoped_lock(scoped_lock const&) /* = delete */;
scoped_lock& operator=(scoped_lock const&) /* = delete */;
public:
explicit
scoped_lock(const volatile void * addr) : mtx_(get_lock_for(addr))
{
mtx_.lock();
}
~scoped_lock()
{
mtx_.unlock();
}
};
private:
static BOOST_ATOMIC_DECL lock_type& get_lock_for(const volatile void * addr);
};
#else
class lockpool
{
public:
typedef atomic_flag lock_type;
class scoped_lock
{
private:
atomic_flag& flag_;
uint8_t padding[128 - sizeof(atomic_flag)];
scoped_lock(const scoped_lock &) /* = delete */;
scoped_lock& operator=(const scoped_lock &) /* = delete */;
public:
explicit
scoped_lock(const volatile void * addr) : flag_(get_lock_for(addr))
{
for (; flag_.test_and_set(memory_order_acquire);)
{
#if defined(BOOST_ATOMIC_X86_PAUSE)
BOOST_ATOMIC_X86_PAUSE();
#endif
}
}
~scoped_lock(void)
{
flag_.clear(memory_order_release);
}
};
private:
static BOOST_ATOMIC_DECL lock_type& get_lock_for(const volatile void * addr);
};
#endif
}
}
}
#endif
|