view release on metacpan or search on metacpan
include/boost/detail/atomic_count_pthreads.hpp
include/boost/detail/atomic_count_win32.hpp
include/boost/detail/bad_weak_ptr.hpp
include/boost/detail/binary_search.hpp
include/boost/detail/call_traits.hpp
include/boost/detail/catch_exceptions.hpp
include/boost/detail/compressed_pair.hpp
include/boost/detail/dynamic_bitset.hpp
include/boost/detail/endian.hpp
include/boost/detail/indirect_traits.hpp
include/boost/detail/interlocked.hpp
include/boost/detail/is_function_ref_tester.hpp
include/boost/detail/is_incrementable.hpp
include/boost/detail/iterator.hpp
include/boost/detail/lightweight_mutex.hpp
include/boost/detail/lightweight_test.hpp
include/boost/detail/limits.hpp
include/boost/detail/lwm_nop.hpp
include/boost/detail/lwm_pthreads.hpp
include/boost/detail/lwm_win32_cs.hpp
include/boost/detail/named_template_params.hpp
include/boost/numeric/ublas/functional.hpp
include/boost/numeric/ublas/fwd.hpp
include/boost/numeric/ublas/hermitian.hpp
include/boost/numeric/ublas/io.hpp
include/boost/numeric/ublas/lu.hpp
include/boost/numeric/ublas/matrix.hpp
include/boost/numeric/ublas/matrix_expression.hpp
include/boost/numeric/ublas/matrix_proxy.hpp
include/boost/numeric/ublas/matrix_sparse.hpp
include/boost/numeric/ublas/operation.hpp
include/boost/numeric/ublas/operation_blocked.hpp
include/boost/numeric/ublas/operation_sparse.hpp
include/boost/numeric/ublas/storage.hpp
include/boost/numeric/ublas/storage_sparse.hpp
include/boost/numeric/ublas/symmetric.hpp
include/boost/numeric/ublas/traits.hpp
include/boost/numeric/ublas/triangular.hpp
include/boost/numeric/ublas/vector.hpp
include/boost/numeric/ublas/vector_expression.hpp
include/boost/numeric/ublas/vector_of_vector.hpp
include/boost/numeric/ublas/vector_proxy.hpp
include/boost/detail/atomic_count_win32.hpp view on Meta::CPAN
//
// boost/detail/atomic_count_win32.hpp
//
// Copyright (c) 2001-2005 Peter Dimov
//
// 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/detail/interlocked.hpp>
namespace boost
{
namespace detail
{
class atomic_count
{
public:
include/boost/detail/interlocked.hpp view on Meta::CPAN
#ifndef BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED
#define BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// boost/detail/interlocked.hpp
//
// Copyright 2005 Peter Dimov
//
// 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/config.hpp>
#if defined( BOOST_USE_WINDOWS_H )
# include <windows.h>
# define BOOST_INTERLOCKED_INCREMENT InterlockedIncrement
# define BOOST_INTERLOCKED_DECREMENT InterlockedDecrement
# define BOOST_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange
#elif defined( BOOST_MSVC ) || defined( BOOST_INTEL_WIN )
extern "C" long __cdecl _InterlockedIncrement( long volatile * );
extern "C" long __cdecl _InterlockedDecrement( long volatile * );
extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long );
# pragma intrinsic( _InterlockedIncrement )
# pragma intrinsic( _InterlockedDecrement )
# pragma intrinsic( _InterlockedCompareExchange )
# define BOOST_INTERLOCKED_INCREMENT _InterlockedIncrement
# define BOOST_INTERLOCKED_DECREMENT _InterlockedDecrement
# define BOOST_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange
#elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ )
namespace boost
{
namespace detail
{
extern "C" __declspec(dllimport) long __stdcall InterlockedIncrement( long volatile * );
extern "C" __declspec(dllimport) long __stdcall InterlockedDecrement( long volatile * );
extern "C" __declspec(dllimport) long __stdcall InterlockedCompareExchange( long volatile *, long, long );
} // namespace detail
} // namespace boost
# define BOOST_INTERLOCKED_INCREMENT InterlockedIncrement
# define BOOST_INTERLOCKED_DECREMENT InterlockedDecrement
# define BOOST_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange
#else
# error "Interlocked intrinsics not available"
#endif
#endif // #ifndef BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED
include/boost/detail/sp_counted_base_w32.hpp view on Meta::CPAN
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//
// Lock-free algorithm by Alexander Terekhov
//
// Thanks to Ben Hitchings for the #weak + (#shared != 0)
// formulation
//
#include <boost/detail/interlocked.hpp>
#include <typeinfo>
namespace boost
{
namespace detail
{
class sp_counted_base
{
include/boost/graph/push_relabel_max_flow.hpp view on Meta::CPAN
// and on the h_prf.c and hi_pr.c code written by the above authors.
// This implements the highest-label version of the push-relabel method
// with the global relabeling and gap relabeling heuristics.
// The terms "rank", "distance", "height" are synonyms in
// Goldberg's implementation, paper and in the CLR. A "layer" is a
// group of vertices with the same distance. The vertices in each
// layer are categorized as active or inactive. An active vertex
// has positive excess flow and its distance is less than n (it is
// not blocked).
template <class Vertex>
struct preflow_layer {
std::list<Vertex> active_vertices;
std::list<Vertex> inactive_vertices;
};
template <class Graph,
class EdgeCapacityMap, // integer value type
class ResidualCapacityEdgeMap,
include/boost/regex/pending/static_mutex.hpp view on Meta::CPAN
};
#define BOOST_STATIC_MUTEX_INIT { PTHREAD_MUTEX_INITIALIZER, }
class BOOST_REGEX_DECL scoped_static_mutex_lock
{
public:
scoped_static_mutex_lock(static_mutex& mut, bool lk = true);
~scoped_static_mutex_lock();
operator void const*()const;
bool locked()const;
void lock();
void unlock();
private:
static_mutex& m_mutex;
bool m_have_lock;
};
inline scoped_static_mutex_lock::operator void const*()const
{
return locked() ? this : 0;
}
inline bool scoped_static_mutex_lock::locked()const
{
return m_have_lock;
}
} // namespace boost
#elif defined(BOOST_HAS_WINTHREADS)
//
// Win32 version:
// Use a 32-bit int as a lock, along with a test-and-set
// implementation using InterlockedCompareExchange.
//
#include <boost/cstdint.hpp>
namespace boost{
class BOOST_REGEX_DECL scoped_static_mutex_lock;
class static_mutex
{
include/boost/regex/pending/static_mutex.hpp view on Meta::CPAN
};
#define BOOST_STATIC_MUTEX_INIT { 0, }
class BOOST_REGEX_DECL scoped_static_mutex_lock
{
public:
scoped_static_mutex_lock(static_mutex& mut, bool lk = true);
~scoped_static_mutex_lock();
operator void const*()const;
bool locked()const;
void lock();
void unlock();
private:
static_mutex& m_mutex;
bool m_have_lock;
scoped_static_mutex_lock(const scoped_static_mutex_lock&);
scoped_static_mutex_lock& operator=(const scoped_static_mutex_lock&);
};
inline scoped_static_mutex_lock::operator void const*()const
{
return locked() ? this : 0;
}
inline bool scoped_static_mutex_lock::locked()const
{
return m_have_lock;
}
} // namespace
#else
//
// Portable version of a static mutex based on Boost.Thread library:
// This has to use a single mutex shared by all instances of static_mutex
include/boost/regex/pending/static_mutex.hpp view on Meta::CPAN
};
#define BOOST_STATIC_MUTEX_INIT { }
class BOOST_REGEX_DECL scoped_static_mutex_lock
{
public:
scoped_static_mutex_lock(static_mutex& mut, bool lk = true);
~scoped_static_mutex_lock();
operator void const*()const;
bool locked()const;
void lock();
void unlock();
private:
boost::recursive_mutex::scoped_lock* m_plock;
bool m_have_lock;
};
inline scoped_static_mutex_lock::operator void const*()const
{
return locked() ? this : 0;
}
inline bool scoped_static_mutex_lock::locked()const
{
return m_have_lock;
}
} // namespace
#endif
#endif
include/boost/signals/connection.hpp view on Meta::CPAN
{ return !(*this < other); }
};
// Describes the connection between a signal and the objects that are
// bound for a specific slot. Enables notification of the signal and the
// slots when a disconnect is requested.
struct basic_connection {
void* signal;
void* signal_data;
void (*signal_disconnect)(void*, void*);
bool blocked_;
std::list<bound_object> bound_objects;
};
} // end namespace detail
// The user may freely pass around the "connection" object and terminate
// the connection at any time using disconnect().
class BOOST_SIGNALS_DECL connection :
private less_than_comparable1<connection>,
private equality_comparable1<connection>
{
public:
connection() : con(), controlling_connection(false) {}
connection(const connection&);
~connection();
// Block he connection: if the connection is still active, there
// will be no notification
void block(bool should_block = true) { con->blocked_ = should_block; }
void unblock() { con->blocked_ = false; }
bool blocked() const { return !connected() || con->blocked_; }
// Disconnect the signal and slot, if they are connected
void disconnect() const;
// Returns true if the signal and slot are connected
bool connected() const { return con.get() && con->signal_disconnect; }
// Comparison of connections
bool operator==(const connection& other) const;
bool operator<(const connection& other) const;
include/boost/signals/connection.hpp view on Meta::CPAN
typedef connection_slot_pair argument_type;
typedef bool result_type;
inline bool operator()(const argument_type& c) const
{
return !c.first.connected();
}
};
// Determines if the underlying connection is callable, ie if
// it is connected and not blocked
struct is_callable {
typedef connection_slot_pair argument_type;
typedef bool result_type;
inline bool operator()(const argument_type& c) const
{
return c.first.connected() && !c.first.blocked() ;
}
};
// Autodisconnects the bound object when it is destroyed unless the
// release method is invoked.
class auto_disconnect_bound_object {
public:
auto_disconnect_bound_object(const bound_object& b) :
binding(b), auto_disconnect(true)
{
include/boost/thread/condition.hpp view on Meta::CPAN
#elif defined(BOOST_HAS_PTHREADS)
void do_wait(pthread_mutex_t* pmutex);
bool do_timed_wait(const xtime& xt, pthread_mutex_t* pmutex);
#endif
#if defined(BOOST_HAS_WINTHREADS)
void* m_gate;
void* m_queue;
void* m_mutex;
unsigned m_gone; // # threads that timed out and never made it to m_queue
unsigned long m_blocked; // # threads blocked on the condition
unsigned m_waiting; // # threads no longer waiting for the condition but
// still waiting to be removed from m_queue
#elif defined(BOOST_HAS_PTHREADS)
pthread_cond_t m_condition;
#elif defined(BOOST_HAS_MPTASKS)
MPSemaphoreID m_gate;
MPSemaphoreID m_queue;
threads::mac::detail::scoped_critical_region m_mutex;
threads::mac::detail::scoped_critical_region m_mutex_mutex;
unsigned m_gone; // # threads that timed out and never made it to m_queue
unsigned long m_blocked; // # threads blocked on the condition
unsigned m_waiting; // # threads no longer waiting for the condition but
// still waiting to be removed from m_queue
#endif
};
} // namespace detail
class condition : private noncopyable
{
public:
include/boost/thread/detail/lock.hpp view on Meta::CPAN
m.do_unlock(state);
}
};
template <typename Mutex>
class scoped_lock : private noncopyable
{
public:
typedef Mutex mutex_type;
explicit scoped_lock(Mutex& mx, bool initially_locked=true)
: m_mutex(mx), m_locked(false)
{
if (initially_locked) lock();
}
~scoped_lock()
{
if (m_locked) unlock();
}
void lock()
{
if (m_locked) throw lock_error();
lock_ops<Mutex>::lock(m_mutex);
m_locked = true;
}
void unlock()
{
if (!m_locked) throw lock_error();
lock_ops<Mutex>::unlock(m_mutex);
m_locked = false;
}
bool locked() const { return m_locked; }
operator const void*() const { return m_locked ? this : 0; }
private:
friend class boost::condition;
Mutex& m_mutex;
bool m_locked;
};
template <typename TryMutex>
class scoped_try_lock : private noncopyable
{
public:
typedef TryMutex mutex_type;
explicit scoped_try_lock(TryMutex& mx)
: m_mutex(mx), m_locked(false)
{
try_lock();
}
scoped_try_lock(TryMutex& mx, bool initially_locked)
: m_mutex(mx), m_locked(false)
{
if (initially_locked) lock();
}
~scoped_try_lock()
{
if (m_locked) unlock();
}
void lock()
{
if (m_locked) throw lock_error();
lock_ops<TryMutex>::lock(m_mutex);
m_locked = true;
}
bool try_lock()
{
if (m_locked) throw lock_error();
return (m_locked = lock_ops<TryMutex>::trylock(m_mutex));
}
void unlock()
{
if (!m_locked) throw lock_error();
lock_ops<TryMutex>::unlock(m_mutex);
m_locked = false;
}
bool locked() const { return m_locked; }
operator const void*() const { return m_locked ? this : 0; }
private:
friend class boost::condition;
TryMutex& m_mutex;
bool m_locked;
};
template <typename TimedMutex>
class scoped_timed_lock : private noncopyable
{
public:
typedef TimedMutex mutex_type;
scoped_timed_lock(TimedMutex& mx, const xtime& xt)
: m_mutex(mx), m_locked(false)
{
timed_lock(xt);
}
scoped_timed_lock(TimedMutex& mx, bool initially_locked)
: m_mutex(mx), m_locked(false)
{
if (initially_locked) lock();
}
~scoped_timed_lock()
{
if (m_locked) unlock();
}
void lock()
{
if (m_locked) throw lock_error();
lock_ops<TimedMutex>::lock(m_mutex);
m_locked = true;
}
bool try_lock()
{
if (m_locked) throw lock_error();
return (m_locked = lock_ops<TimedMutex>::trylock(m_mutex));
}
bool timed_lock(const xtime& xt)
{
if (m_locked) throw lock_error();
return (m_locked = lock_ops<TimedMutex>::timedlock(m_mutex, xt));
}
void unlock()
{
if (!m_locked) throw lock_error();
lock_ops<TimedMutex>::unlock(m_mutex);
m_locked = false;
}
bool locked() const { return m_locked; }
operator const void*() const { return m_locked ? this : 0; }
private:
friend class boost::condition;
TimedMutex& m_mutex;
bool m_locked;
};
} // namespace thread
} // namespace detail
} // namespace boost
#endif // BOOST_XLOCK_WEK070601_HPP
// Change Log:
// 8 Feb 01 WEKEMPF Initial version.
// 22 May 01 WEKEMPF Modified to use xtime for time outs.
// 30 Jul 01 WEKEMPF Moved lock types into boost::detail::thread. Renamed
// some types. Added locked() methods.
include/boost/thread/detail/read_write_lock.hpp view on Meta::CPAN
#include <boost/thread/exceptions.hpp>
#include <boost/thread/detail/lock.hpp>
namespace boost {
struct xtime;
namespace read_write_lock_state {
enum read_write_lock_state_enum
{
unlocked=0,
read_locked=1,
write_locked=2
};
} //namespace read_write_lock_state
namespace detail {
namespace thread {
template <typename Mutex>
class read_write_lock_ops : private noncopyable
{
private:
include/boost/thread/detail/read_write_lock.hpp view on Meta::CPAN
template <typename ReadWriteMutex>
class scoped_read_write_lock : private noncopyable
{
public:
typedef ReadWriteMutex mutex_type;
scoped_read_write_lock(
ReadWriteMutex& mx,
read_write_lock_state::read_write_lock_state_enum initial_state)
: m_mutex(mx), m_state(read_write_lock_state::unlocked)
{
if (initial_state == read_write_lock_state::read_locked)
read_lock();
else if (initial_state == read_write_lock_state::write_locked)
write_lock();
}
~scoped_read_write_lock()
{
if (m_state != read_write_lock_state::unlocked)
unlock();
}
void read_lock()
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
read_write_lock_ops<ReadWriteMutex>::read_lock(m_mutex);
m_state = read_write_lock_state::read_locked;
}
void write_lock()
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
read_write_lock_ops<ReadWriteMutex>::write_lock(m_mutex);
m_state = read_write_lock_state::write_locked;
}
void unlock()
{
if (m_state == read_write_lock_state::unlocked) throw lock_error();
if (m_state == read_write_lock_state::read_locked)
read_write_lock_ops<ReadWriteMutex>::read_unlock(m_mutex);
else //(m_state == read_write_lock_state::write_locked)
read_write_lock_ops<ReadWriteMutex>::write_unlock(m_mutex);
m_state = read_write_lock_state::unlocked;
}
void demote(void)
{
if (m_state != read_write_lock_state::write_locked) throw lock_error();
read_write_lock_ops<ReadWriteMutex>::demote(m_mutex);
m_state = read_write_lock_state::read_locked;
}
void promote(void)
{
if (m_state != read_write_lock_state::read_locked) throw lock_error();
read_write_lock_ops<ReadWriteMutex>::promote(m_mutex);
m_state = read_write_lock_state::write_locked;
}
//If allow_unlock = true, set_lock always succeeds and
//the function result indicates whether an unlock was required.
//If allow_unlock = false, set_lock may fail;
//the function result indicates whether it succeeded.
bool set_lock(read_write_lock_state::read_write_lock_state_enum ls, bool allow_unlock = true)
{
bool result = !allow_unlock;
if (m_state != ls)
{
if (m_state == read_write_lock_state::unlocked)
{
if (ls == read_write_lock_state::read_locked)
read_lock();
else //(ls == read_write_lock_state::write_locked)
write_lock();
}
else //(m_state == read_write_lock_state::read_locked || m_state == read_write_lock_state::write_locked)
{
if (ls == read_write_lock_state::read_locked)
demote();
else if (ls == read_write_lock_state::write_locked)
{
if (allow_unlock)
{
result = true;
unlock();
write_lock();
}
else
result = false;
}
else //(ls == read_write_lock_state::unlocked)
unlock();
}
}
return result;
}
bool locked() const
{
return m_state != read_write_lock_state::unlocked;
}
bool read_locked() const
{
return m_state == read_write_lock_state::read_locked;
}
bool write_locked() const
{
return m_state != read_write_lock_state::write_locked;
}
operator const void*() const
{
return (m_state != read_write_lock_state::unlocked) ? this : 0;
}
read_write_lock_state::read_write_lock_state_enum state() const
{
return m_state;
}
private:
ReadWriteMutex& m_mutex;
include/boost/thread/detail/read_write_lock.hpp view on Meta::CPAN
template <typename ReadWriteMutex>
class scoped_read_lock : private noncopyable
{
public:
typedef ReadWriteMutex mutex_type;
explicit scoped_read_lock(
ReadWriteMutex& mx,
bool initially_locked = true)
: m_mutex(mx), m_state(read_write_lock_state::unlocked)
{
if (initially_locked)
lock();
}
~scoped_read_lock()
{
if (m_state != read_write_lock_state::unlocked)
unlock();
}
void lock()
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
read_write_lock_ops<ReadWriteMutex>::read_lock(m_mutex);
m_state = read_write_lock_state::read_locked;
}
void unlock()
{
if (m_state != read_write_lock_state::read_locked) throw lock_error();
read_write_lock_ops<ReadWriteMutex>::read_unlock(m_mutex);
m_state = read_write_lock_state::unlocked;
}
bool locked() const
{
return m_state != read_write_lock_state::unlocked;
}
operator const void*() const
{
return (m_state != read_write_lock_state::unlocked) ? this : 0;
}
private:
ReadWriteMutex& m_mutex;
read_write_lock_state::read_write_lock_state_enum m_state;
};
template <typename ReadWriteMutex>
class scoped_write_lock : private noncopyable
{
public:
typedef ReadWriteMutex mutex_type;
explicit scoped_write_lock(
ReadWriteMutex& mx,
bool initially_locked = true)
: m_mutex(mx), m_state(read_write_lock_state::unlocked)
{
if (initially_locked)
lock();
}
~scoped_write_lock()
{
if (m_state != read_write_lock_state::unlocked)
unlock();
}
void lock()
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
read_write_lock_ops<ReadWriteMutex>::write_lock(m_mutex);
m_state = read_write_lock_state::write_locked;
}
void unlock()
{
if (m_state != read_write_lock_state::write_locked) throw lock_error();
read_write_lock_ops<ReadWriteMutex>::write_unlock(m_mutex);
m_state = read_write_lock_state::unlocked;
}
bool locked() const
{
return m_state != read_write_lock_state::unlocked;
}
operator const void*() const
{
return (m_state != read_write_lock_state::unlocked) ? this : 0;
}
private:
ReadWriteMutex& m_mutex;
read_write_lock_state::read_write_lock_state_enum m_state;
};
template <typename TryReadWriteMutex>
class scoped_try_read_write_lock : private noncopyable
{
public:
typedef TryReadWriteMutex mutex_type;
scoped_try_read_write_lock(
TryReadWriteMutex& mx,
read_write_lock_state::read_write_lock_state_enum initial_state)
: m_mutex(mx), m_state(read_write_lock_state::unlocked)
{
if (initial_state == read_write_lock_state::read_locked)
read_lock();
else if (initial_state == read_write_lock_state::write_locked)
write_lock();
}
~scoped_try_read_write_lock()
{
if (m_state != read_write_lock_state::unlocked)
unlock();
}
void read_lock()
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
read_write_lock_ops<TryReadWriteMutex>::read_lock(m_mutex);
m_state = read_write_lock_state::read_locked;
}
bool try_read_lock()
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
if(read_write_lock_ops<TryReadWriteMutex>::try_read_lock(m_mutex))
{
m_state = read_write_lock_state::read_locked;
return true;
}
return false;
}
void write_lock()
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
read_write_lock_ops<TryReadWriteMutex>::write_lock(m_mutex);
m_state = read_write_lock_state::write_locked;
}
bool try_write_lock()
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
if(read_write_lock_ops<TryReadWriteMutex>::try_write_lock(m_mutex))
{
m_state = read_write_lock_state::write_locked;
return true;
}
return false;
}
void unlock()
{
if (m_state == read_write_lock_state::unlocked) throw lock_error();
if (m_state == read_write_lock_state::read_locked)
read_write_lock_ops<TryReadWriteMutex>::read_unlock(m_mutex);
else //(m_state == read_write_lock_state::write_locked)
read_write_lock_ops<TryReadWriteMutex>::write_unlock(m_mutex);
m_state = read_write_lock_state::unlocked;
}
void demote(void)
{
if (m_state != read_write_lock_state::write_locked) throw lock_error();
read_write_lock_ops<TryReadWriteMutex>::demote(m_mutex);
m_state = read_write_lock_state::read_locked;
}
bool try_demote(void)
{
if (m_state != read_write_lock_state::write_locked) throw lock_error();
return read_write_lock_ops<TryReadWriteMutex>::try_demote(m_mutex) ? (m_state = read_write_lock_state::read_locked, true) : false;
}
void promote(void)
{
if (m_state != read_write_lock_state::read_locked) throw lock_error();
read_write_lock_ops<TryReadWriteMutex>::promote(m_mutex);
m_state = read_write_lock_state::write_locked;
}
bool try_promote(void)
{
if (m_state != read_write_lock_state::read_locked) throw lock_error();
return read_write_lock_ops<TryReadWriteMutex>::try_promote(m_mutex) ? (m_state = read_write_lock_state::write_locked, true) : false;
}
//If allow_unlock = true, set_lock always succeeds and
//the function result indicates whether an unlock was required.
//If allow_unlock = false, set_lock may fail;
//the function result indicates whether it succeeded.
bool set_lock(read_write_lock_state::read_write_lock_state_enum ls, bool allow_unlock = true)
{
bool result = !allow_unlock;
if (m_state != ls)
{
if (m_state == read_write_lock_state::unlocked)
{
if (ls == read_write_lock_state::read_locked)
read_lock();
else //(ls == read_write_lock_state::write_locked)
write_lock();
}
else //(m_state == read_write_lock_state::read_locked || m_state == read_write_lock_state::write_locked)
{
if (ls == read_write_lock_state::read_locked)
demote();
else if (ls == read_write_lock_state::write_locked)
{
if (!try_promote())
{
if (allow_unlock)
{
result = true;
unlock();
write_lock();
}
else
result = false;
}
}
else //(ls == read_write_lock_state::unlocked)
unlock();
}
}
return result;
}
bool try_set_lock(read_write_lock_state::read_write_lock_state_enum ls)
{
if (m_state != ls)
{
if (m_state == read_write_lock_state::unlocked)
{
if (ls == read_write_lock_state::read_locked)
return try_read_lock();
else // (ls == read_write_lock_state::write_locked)
return try_write_lock();
}
else //(m_state == read_write_lock_state::read_locked || m_state == read_write_lock_state::write_locked)
{
if (ls == read_write_lock_state::read_locked)
return try_demote();
else if (ls == read_write_lock_state::write_locked)
return try_promote();
else //(ls == read_write_lock_state::unlocked)
return unlock(), true;
}
}
else //(m_state == ls)
return true;
}
bool locked() const
{
return m_state != read_write_lock_state::unlocked;
}
bool read_locked() const
{
return m_state == read_write_lock_state::read_locked;
}
bool write_locked() const
{
return m_state != read_write_lock_state::write_locked;
}
operator const void*() const
{
return (m_state != read_write_lock_state::unlocked) ? this : 0;
}
read_write_lock_state::read_write_lock_state_enum state() const
{
return m_state;
}
private:
TryReadWriteMutex& m_mutex;
include/boost/thread/detail/read_write_lock.hpp view on Meta::CPAN
template <typename TryReadWriteMutex>
class scoped_try_read_lock : private noncopyable
{
public:
typedef TryReadWriteMutex mutex_type;
explicit scoped_try_read_lock(
TryReadWriteMutex& mx,
bool initially_locked = true)
: m_mutex(mx), m_state(read_write_lock_state::unlocked)
{
if (initially_locked)
lock();
}
~scoped_try_read_lock()
{
if (m_state != read_write_lock_state::unlocked)
unlock();
}
void lock()
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
read_write_lock_ops<TryReadWriteMutex>::read_lock(m_mutex);
m_state = read_write_lock_state::read_locked;
}
bool try_lock()
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
if(read_write_lock_ops<TryReadWriteMutex>::try_read_lock(m_mutex))
{
m_state = read_write_lock_state::read_locked;
return true;
}
return false;
}
void unlock()
{
if (m_state != read_write_lock_state::read_locked) throw lock_error();
read_write_lock_ops<TryReadWriteMutex>::read_unlock(m_mutex);
m_state = read_write_lock_state::unlocked;
}
bool locked() const
{
return m_state != read_write_lock_state::unlocked;
}
operator const void*() const
{
return (m_state != read_write_lock_state::unlocked) ? this : 0;
}
private:
TryReadWriteMutex& m_mutex;
read_write_lock_state::read_write_lock_state_enum m_state;
};
template <typename TryReadWriteMutex>
class scoped_try_write_lock : private noncopyable
{
public:
typedef TryReadWriteMutex mutex_type;
explicit scoped_try_write_lock(
TryReadWriteMutex& mx,
bool initially_locked = true)
: m_mutex(mx), m_state(read_write_lock_state::unlocked)
{
if (initially_locked)
lock();
}
~scoped_try_write_lock()
{
if (m_state != read_write_lock_state::unlocked)
unlock();
}
void lock()
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
read_write_lock_ops<TryReadWriteMutex>::write_lock(m_mutex);
m_state = read_write_lock_state::write_locked;
}
bool try_lock()
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
if(read_write_lock_ops<TryReadWriteMutex>::try_write_lock(m_mutex))
{
m_state = read_write_lock_state::write_locked;
return true;
}
return false;
}
void unlock()
{
if (m_state != read_write_lock_state::write_locked) throw lock_error();
read_write_lock_ops<TryReadWriteMutex>::write_unlock(m_mutex);
m_state = read_write_lock_state::unlocked;
}
bool locked() const
{
return m_state != read_write_lock_state::unlocked;
}
operator const void*() const
{
return (m_state != read_write_lock_state::unlocked) ? this : 0;
}
private:
TryReadWriteMutex& m_mutex;
read_write_lock_state::read_write_lock_state_enum m_state;
};
template <typename TimedReadWriteMutex>
class scoped_timed_read_write_lock : private noncopyable
{
public:
typedef TimedReadWriteMutex mutex_type;
scoped_timed_read_write_lock(
TimedReadWriteMutex& mx,
read_write_lock_state::read_write_lock_state_enum initial_state)
: m_mutex(mx), m_state(read_write_lock_state::unlocked)
{
if (initial_state == read_write_lock_state::read_locked)
read_lock();
else if (initial_state == read_write_lock_state::write_locked)
write_lock();
}
~scoped_timed_read_write_lock()
{
if (m_state != read_write_lock_state::unlocked)
unlock();
}
void read_lock()
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
read_write_lock_ops<TimedReadWriteMutex>::read_lock(m_mutex);
m_state = read_write_lock_state::read_locked;
}
bool try_read_lock()
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
if(read_write_lock_ops<TimedReadWriteMutex>::try_read_lock(m_mutex))
{
m_state = read_write_lock_state::read_locked;
return true;
}
return false;
}
bool timed_read_lock(const xtime &xt)
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
if(read_write_lock_ops<TimedReadWriteMutex>::timed_read_lock(m_mutex,xt))
{
m_state = read_write_lock_state::read_locked;
return true;
}
return false;
}
void write_lock()
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
read_write_lock_ops<TimedReadWriteMutex>::write_lock(m_mutex);
m_state = read_write_lock_state::write_locked;
}
bool try_write_lock()
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
if(read_write_lock_ops<TimedReadWriteMutex>::try_write_lock(m_mutex))
{
m_state = read_write_lock_state::write_locked;
return true;
}
return false;
}
bool timed_write_lock(const xtime &xt)
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
if(read_write_lock_ops<TimedReadWriteMutex>::timed_write_lock(m_mutex,xt))
{
m_state = read_write_lock_state::write_locked;
return true;
}
return false;
}
void unlock()
{
if (m_state == read_write_lock_state::unlocked) throw lock_error();
if (m_state == read_write_lock_state::read_locked)
read_write_lock_ops<TimedReadWriteMutex>::read_unlock(m_mutex);
else //(m_state == read_write_lock_state::write_locked)
read_write_lock_ops<TimedReadWriteMutex>::write_unlock(m_mutex);
m_state = read_write_lock_state::unlocked;
}
void demote(void)
{
if (m_state != read_write_lock_state::write_locked) throw lock_error();
read_write_lock_ops<TimedReadWriteMutex>::demote(m_mutex);
m_state = read_write_lock_state::read_locked;
}
bool try_demote(void)
{
if (m_state != read_write_lock_state::write_locked) throw lock_error();
return read_write_lock_ops<TimedReadWriteMutex>::try_demote(m_mutex) ? (m_state = read_write_lock_state::read_locked, true) : false;
}
bool timed_demote(const xtime &xt)
{
if (m_state != read_write_lock_state::write_locked) throw lock_error();
return read_write_lock_ops<TimedReadWriteMutex>::timed_demote(m_mutex, xt) ? (m_state = read_write_lock_state::read_locked, true) : false;
}
void promote(void)
{
if (m_state != read_write_lock_state::read_locked) throw lock_error();
read_write_lock_ops<TimedReadWriteMutex>::promote(m_mutex);
m_state = read_write_lock_state::write_locked;
}
bool try_promote(void)
{
if (m_state != read_write_lock_state::read_locked) throw lock_error();
return read_write_lock_ops<TimedReadWriteMutex>::try_promote(m_mutex) ? (m_state = read_write_lock_state::write_locked, true) : false;
}
bool timed_promote(const xtime &xt)
{
if (m_state != read_write_lock_state::read_locked) throw lock_error();
return read_write_lock_ops<TimedReadWriteMutex>::timed_promote(m_mutex, xt) ? (m_state = read_write_lock_state::write_locked, true) : false;
}
//If allow_unlock = true, set_lock always succeeds and
//the function result indicates whether an unlock was required.
//If allow_unlock = false, set_lock may fail;
//the function result indicates whether it succeeded.
bool set_lock(read_write_lock_state::read_write_lock_state_enum ls, bool allow_unlock = true)
{
bool result = !allow_unlock;
if (m_state != ls)
{
if (m_state == read_write_lock_state::unlocked)
{
if (ls == read_write_lock_state::read_locked)
read_lock();
else //(ls == read_write_lock_state::write_locked)
write_lock();
}
else //(m_state == read_write_lock_state::read_locked || m_state == read_write_lock_state::write_locked)
{
if (ls == read_write_lock_state::read_locked)
demote();
else if (ls == read_write_lock_state::write_locked)
{
if (!try_promote())
{
if (allow_unlock)
{
result = true;
unlock();
write_lock();
}
else
result = false;
}
}
else //(ls == read_write_lock_state::unlocked)
unlock();
}
}
return result;
}
bool try_set_lock(read_write_lock_state::read_write_lock_state_enum ls)
{
if (m_state != ls)
{
if (m_state == read_write_lock_state::unlocked)
{
if (ls == read_write_lock_state::read_locked)
return try_read_lock();
else // (ls == read_write_lock_state::write_locked)
return try_write_lock();
}
else //(m_state == read_write_lock_state::read_locked || m_state == read_write_lock_state::write_locked)
{
if (ls == read_write_lock_state::read_locked)
return try_demote();
else if (ls == read_write_lock_state::write_locked)
return try_promote();
else //(ls == read_write_lock_state::unlocked)
return unlock(), true;
}
}
else //(m_state == ls)
return true;
}
bool timed_set_lock(read_write_lock_state::read_write_lock_state_enum ls, const xtime &xt)
{
if (m_state != ls)
{
if (m_state == read_write_lock_state::unlocked)
{
if (ls == read_write_lock_state::read_locked)
return timed_read_lock(xt);
else // (ls == read_write_lock_state::write_locked)
return timed_write_lock(xt);
}
else //(m_state == read_write_lock_state::read_locked || m_state == read_write_lock_state::write_locked)
{
if (ls == read_write_lock_state::read_locked)
return timed_demote(xt);
else if (ls == read_write_lock_state::write_locked)
return timed_promote(xt);
else //(ls == read_write_lock_state::unlocked)
return unlock(), true;
}
}
else //(m_state == ls)
return true;
}
bool locked() const
{
return m_state != read_write_lock_state::unlocked;
}
bool read_locked() const
{
return m_state == read_write_lock_state::read_locked;
}
bool write_locked() const
{
return m_state != read_write_lock_state::write_locked;
}
operator const void*() const
{
return (m_state != read_write_lock_state::unlocked) ? this : 0;
}
read_write_lock_state::read_write_lock_state_enum state() const
{
return m_state;
}
private:
TimedReadWriteMutex& m_mutex;
include/boost/thread/detail/read_write_lock.hpp view on Meta::CPAN
template <typename TimedReadWriteMutex>
class scoped_timed_read_lock : private noncopyable
{
public:
typedef TimedReadWriteMutex mutex_type;
explicit scoped_timed_read_lock(
TimedReadWriteMutex& mx,
bool initially_locked = true)
: m_mutex(mx), m_state(read_write_lock_state::unlocked)
{
if (initially_locked)
lock();
}
~scoped_timed_read_lock()
{
if (m_state != read_write_lock_state::unlocked)
unlock();
}
void lock()
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
read_write_lock_ops<TimedReadWriteMutex>::read_lock(m_mutex);
m_state = read_write_lock_state::read_locked;
}
bool try_lock()
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
if(read_write_lock_ops<TimedReadWriteMutex>::try_read_lock(m_mutex))
{
m_state = read_write_lock_state::read_locked;
return true;
}
return false;
}
bool timed_lock(const xtime &xt)
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
if(read_write_lock_ops<TimedReadWriteMutex>::timed_read_lock(m_mutex,xt))
{
m_state = read_write_lock_state::read_locked;
return true;
}
return false;
}
void unlock()
{
if (m_state != read_write_lock_state::read_locked) throw lock_error();
read_write_lock_ops<TimedReadWriteMutex>::read_unlock(m_mutex);
m_state = read_write_lock_state::unlocked;
}
bool locked() const
{
return m_state != read_write_lock_state::unlocked;
}
operator const void*() const
{
return (m_state != read_write_lock_state::unlocked) ? this : 0;
}
read_write_lock_state::read_write_lock_state_enum state() const
{
return m_state;
}
private:
TimedReadWriteMutex& m_mutex;
include/boost/thread/detail/read_write_lock.hpp view on Meta::CPAN
template <typename TimedReadWriteMutex>
class scoped_timed_write_lock : private noncopyable
{
public:
typedef TimedReadWriteMutex mutex_type;
explicit scoped_timed_write_lock(
TimedReadWriteMutex& mx,
bool initially_locked = true)
: m_mutex(mx), m_state(read_write_lock_state::unlocked)
{
if (initially_locked)
lock();
}
~scoped_timed_write_lock()
{
if (m_state != read_write_lock_state::unlocked)
unlock();
}
void lock()
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
read_write_lock_ops<TimedReadWriteMutex>::write_lock(m_mutex);
m_state = read_write_lock_state::write_locked;
}
bool try_lock()
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
if(read_write_lock_ops<TimedReadWriteMutex>::try_write_lock(m_mutex))
{
m_state = read_write_lock_state::write_locked;
return true;
}
return false;
}
bool timed_lock(const xtime &xt)
{
if (m_state != read_write_lock_state::unlocked) throw lock_error();
if(read_write_lock_ops<TimedReadWriteMutex>::timed_write_lock(m_mutex,xt))
{
m_state = read_write_lock_state::write_locked;
return true;
}
return false;
}
void unlock()
{
if (m_state != read_write_lock_state::write_locked) throw lock_error();
read_write_lock_ops<TimedReadWriteMutex>::write_unlock(m_mutex);
m_state = read_write_lock_state::unlocked;
}
bool locked() const
{
return m_state != read_write_lock_state::unlocked;
}
operator const void*() const
{
return (m_state != read_write_lock_state::unlocked) ? this : 0;
}
read_write_lock_state::read_write_lock_state_enum state() const
{
return m_state;
}
private:
TimedReadWriteMutex& m_mutex;
include/boost/thread/mutex.hpp view on Meta::CPAN
bool do_timedlock(const xtime& xt);
void do_unlock();
void do_lock(cv_state& state);
void do_unlock(cv_state& state);
#if defined(BOOST_HAS_WINTHREADS)
void* m_mutex;
#elif defined(BOOST_HAS_PTHREADS)
pthread_mutex_t m_mutex;
pthread_cond_t m_condition;
bool m_locked;
#elif defined(BOOST_HAS_MPTASKS)
threads::mac::detail::scoped_critical_region m_mutex;
threads::mac::detail::scoped_critical_region m_mutex_mutex;
#endif
};
} // namespace boost
// Change Log:
// 8 Feb 01 WEKEMPF Initial version.
include/boost/thread/read_write_mutex.hpp view on Meta::CPAN
typedef detail::thread::scoped_timed_lock<Mutex> scoped_timed_lock;
read_write_mutex_impl(read_write_scheduling_policy::read_write_scheduling_policy_enum sp);
#if !BOOST_WORKAROUND(__BORLANDC__,<= 0x564)
~read_write_mutex_impl();
#endif
Mutex m_prot;
const read_write_scheduling_policy::read_write_scheduling_policy_enum m_sp;
int m_state; //-1 = write lock; 0 = unlocked; >0 = read locked
boost::condition m_waiting_writers;
boost::condition m_waiting_readers;
boost::condition m_waiting_promotion;
int m_num_waiting_writers;
int m_num_waiting_readers;
bool m_state_waiting_promotion;
int m_num_waking_writers;
int m_num_waking_readers;
include/boost/thread/read_write_mutex.hpp view on Meta::CPAN
bool do_timed_read_lock(const xtime &xt);
void do_demote_to_read_lock();
bool do_try_demote_to_read_lock();
bool do_timed_demote_to_read_lock(const xtime &xt);
void do_promote_to_write_lock();
bool do_try_promote_to_write_lock();
bool do_timed_promote_to_write_lock(const xtime &xt);
bool locked();
read_write_lock_state::read_write_lock_state_enum state();
private:
bool do_demote_to_read_lock_impl();
enum scheduling_reason
{
scheduling_reason_unlock,
scheduling_reason_timeout,
include/boost/thread/read_write_mutex.hpp view on Meta::CPAN
// via lock types
void do_write_lock();
void do_read_lock();
void do_write_unlock();
void do_read_unlock();
void do_demote_to_read_lock();
void do_promote_to_write_lock();
bool locked();
read_write_lock_state::read_write_lock_state_enum state();
detail::thread::read_write_mutex_impl<mutex> m_impl;
};
class BOOST_THREAD_DECL try_read_write_mutex : private noncopyable
{
public:
try_read_write_mutex(read_write_scheduling_policy::read_write_scheduling_policy_enum sp);
include/boost/thread/read_write_mutex.hpp view on Meta::CPAN
bool do_try_write_lock();
bool do_try_read_lock();
void do_demote_to_read_lock();
bool do_try_demote_to_read_lock();
void do_promote_to_write_lock();
bool do_try_promote_to_write_lock();
bool locked();
read_write_lock_state::read_write_lock_state_enum state();
detail::thread::read_write_mutex_impl<try_mutex> m_impl;
};
class BOOST_THREAD_DECL timed_read_write_mutex : private noncopyable
{
public:
timed_read_write_mutex(read_write_scheduling_policy::read_write_scheduling_policy_enum sp);
include/boost/thread/read_write_mutex.hpp view on Meta::CPAN
bool do_timed_read_lock(const xtime &xt);
void do_demote_to_read_lock();
bool do_try_demote_to_read_lock();
bool do_timed_demote_to_read_lock(const xtime &xt);
void do_promote_to_write_lock();
bool do_try_promote_to_write_lock();
bool do_timed_promote_to_write_lock(const xtime &xt);
bool locked();
read_write_lock_state::read_write_lock_state_enum state();
detail::thread::read_write_mutex_impl<timed_mutex> m_impl;
};
} // namespace boost
#endif
// Change Log:
// 10 Mar 02
// Original version.
// 4 May 04 GlassfordM
// Implement lock promotion and demotion.
// Add locked() and state() member functions for debugging
// (should these be made public?).
// Rename to improve consistency and eliminate abbreviations:
// Use "read" and "write" instead of "shared" and "exclusive".
// Change "rd" to "read", "wr" to "write", "rw" to "read_write".
// Add mutex_type typdef.
include/boost/thread/recursive_mutex.hpp view on Meta::CPAN
void do_unlock(cv_state& state);
#if defined(BOOST_HAS_WINTHREADS)
void* m_mutex;
bool m_critical_section;
unsigned long m_count;
#elif defined(BOOST_HAS_PTHREADS)
pthread_mutex_t m_mutex;
unsigned m_count;
# if !defined(BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE)
pthread_cond_t m_unlocked;
pthread_t m_thread_id;
bool m_valid_id;
# endif
#elif defined(BOOST_HAS_MPTASKS)
threads::mac::detail::scoped_critical_region m_mutex;
threads::mac::detail::scoped_critical_region m_mutex_mutex;
std::size_t m_count;
#endif
};
include/boost/thread/recursive_mutex.hpp view on Meta::CPAN
void do_unlock(cv_state& state);
#if defined(BOOST_HAS_WINTHREADS)
void* m_mutex;
bool m_critical_section;
unsigned long m_count;
#elif defined(BOOST_HAS_PTHREADS)
pthread_mutex_t m_mutex;
unsigned m_count;
# if !defined(BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE)
pthread_cond_t m_unlocked;
pthread_t m_thread_id;
bool m_valid_id;
# endif
#elif defined(BOOST_HAS_MPTASKS)
threads::mac::detail::scoped_critical_region m_mutex;
threads::mac::detail::scoped_critical_region m_mutex_mutex;
std::size_t m_count;
#endif
};
include/boost/thread/recursive_mutex.hpp view on Meta::CPAN
bool do_timedlock(const xtime& xt);
void do_unlock();
void do_lock(cv_state& state);
void do_unlock(cv_state& state);
#if defined(BOOST_HAS_WINTHREADS)
void* m_mutex;
unsigned long m_count;
#elif defined(BOOST_HAS_PTHREADS)
pthread_mutex_t m_mutex;
pthread_cond_t m_unlocked;
pthread_t m_thread_id;
bool m_valid_id;
unsigned m_count;
#elif defined(BOOST_HAS_MPTASKS)
threads::mac::detail::scoped_critical_region m_mutex;
threads::mac::detail::scoped_critical_region m_mutex_mutex;
std::size_t m_count;
#endif
};