/usr/include/stxxl/bits/common/state.h is in libstxxl-dev 1.4.0-3.
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 | /***************************************************************************
* include/stxxl/bits/common/state.h
*
* Part of the STXXL. See http://stxxl.sourceforge.net
*
* Copyright (C) 2002 Roman Dementiev <dementiev@mpi-sb.mpg.de>
* Copyright (C) 2008 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
* Copyright (C) 2013 Timo Bingmann <tb@panthema.net>
*
* 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)
**************************************************************************/
#ifndef STXXL_COMMON_STATE_HEADER
#define STXXL_COMMON_STATE_HEADER
#include <stxxl/bits/noncopyable.h>
#include <stxxl/bits/common/mutex.h>
#include <stxxl/bits/common/condition_variable.h>
STXXL_BEGIN_NAMESPACE
template <typename ValueType = int>
class state : private noncopyable
{
typedef ValueType value_type;
//! mutex for condition variable
mutex m_mutex;
//! condition variable
condition_variable m_cond;
//! current state
value_type m_state;
public:
state(const value_type& s)
: m_state(s)
{ }
void set_to(const value_type& new_state)
{
scoped_mutex_lock lock(m_mutex);
m_state = new_state;
lock.unlock();
m_cond.notify_all();
}
void wait_for(const value_type& needed_state)
{
scoped_mutex_lock lock(m_mutex);
while (needed_state != m_state)
m_cond.wait(lock);
}
value_type operator () ()
{
scoped_mutex_lock lock(m_mutex);
return m_state;
}
};
STXXL_END_NAMESPACE
#endif // !STXXL_COMMON_STATE_HEADER
|