From 5f750fa386fe7c38bb9963d3ee2c635f7ea984c3 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Fri, 15 Jun 2001 15:31:38 +0000 Subject: [PATCH] Due to misspelling of branch name, these got put in the main trunk. So remove them from the main trunk [SVN r10339] --- include/boost/thread/_atomic.hpp | 61 --------- include/boost/thread/condition.hpp | 156 --------------------- include/boost/thread/config.hpp | 65 --------- include/boost/thread/mutex.hpp | 147 -------------------- include/boost/thread/recursive_mutex.hpp | 167 ----------------------- include/boost/thread/semaphore.hpp | 57 -------- include/boost/thread/thread.hpp | 88 ------------ include/boost/thread/tss.hpp | 49 ------- include/boost/thread/xlock.hpp | 163 ---------------------- include/boost/thread/xtime.hpp | 49 ------- 10 files changed, 1002 deletions(-) delete mode 100644 include/boost/thread/_atomic.hpp delete mode 100644 include/boost/thread/condition.hpp delete mode 100644 include/boost/thread/config.hpp delete mode 100644 include/boost/thread/mutex.hpp delete mode 100644 include/boost/thread/recursive_mutex.hpp delete mode 100644 include/boost/thread/semaphore.hpp delete mode 100644 include/boost/thread/thread.hpp delete mode 100644 include/boost/thread/tss.hpp delete mode 100644 include/boost/thread/xlock.hpp delete mode 100644 include/boost/thread/xtime.hpp diff --git a/include/boost/thread/_atomic.hpp b/include/boost/thread/_atomic.hpp deleted file mode 100644 index 463f8f61..00000000 --- a/include/boost/thread/_atomic.hpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * - * Copyright (C) 2001 - * William E. Kempf - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. William E. Kempf makes no representations - * about the suitability of this software for any purpose. - * It is provided "as is" without express or implied warranty. - * - * Revision History (excluding minor changes for specific compilers) - * 8 Feb 01 Initial version. - */ - -#ifndef BOOST_ATOMIC_HPP -#define BOOST_ATOMIC_HPP - -#include -#ifndef BOOST_HAS_THREADS -# error Thread support is unavailable! -#endif - -#if !defined(BOOST_HAS_WINTHREADS) -# include -#endif - -namespace boost { - class atomic_t - { - public: - typedef long value_type; - - friend value_type read(const atomic_t&); - friend value_type increment(atomic_t&); - friend value_type decrement(atomic_t&); - friend value_type swap(atomic_t&, value_type); - friend value_type compare_swap(atomic_t&, value_type, value_type); - - explicit atomic_t(value_type val=0) - : _value(val) - { - } - - private: - volatile value_type _value; -#if !defined(BOOST_HAS_WINTHREADS) - mutex _mutex; -#endif - }; - - extern atomic_t::value_type read(const atomic_t&); - extern atomic_t::value_type increment(atomic_t&); - extern atomic_t::value_type decrement(atomic_t&); - extern atomic_t::value_type swap(atomic_t&, atomic_t::value_type); - extern atomic_t::value_type compare_swap(atomic_t&, atomic_t::value_type, atomic_t::value_type); -} // namespace boost - -#endif // BOOST_ATOMIC_HPP diff --git a/include/boost/thread/condition.hpp b/include/boost/thread/condition.hpp deleted file mode 100644 index 38e4f7a5..00000000 --- a/include/boost/thread/condition.hpp +++ /dev/null @@ -1,156 +0,0 @@ -/* - * - * Copyright (C) 2001 - * William E. Kempf - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. William E. Kempf makes no representations - * about the suitability of this software for any purpose. - * It is provided "as is" without express or implied warranty. - * - * Revision History (excluding minor changes for specific compilers) - * 8 Feb 01 Initial version. - * 22 May 01 Modified to use xtime for time outs. - * 23 May 01 Removed "duration" timed_waits, as they are too difficult - * to use with spurious wakeups. - */ - -#ifndef BOOST_CONDITION_HPP -#define BOOST_CONDITION_HPP - -#include -#ifndef BOOST_HAS_THREADS -# error Thread support is unavailable! -#endif - -#include -#include - -#if defined(BOOST_HAS_PTHREADS) -# include -#endif - -namespace boost -{ - class condition : private noncopyable - { - public: - condition(); - ~condition(); - - void notify_one(); - void notify_all(); - - template - void wait(L& lock) - { - if (!lock) - throw lock_error(); - - do_wait(lock._mutex); - } - - template - void wait(L& lock, Pr pred) - { - if (!lock) - throw lock_error(); - - while (!pred()) - do_wait(lock._mutex); - } - - template - bool timed_wait(L& lock, const xtime& xt) - { - if (!lock) - throw lock_error(); - - return do_timed_wait(lock._mutex, xt); - } - - template - bool timed_wait(L& lock, const xtime& xt, Pr pred) - { - if (!lock) - throw lock_error(); - - while (!pred()) - { - if (!do_timed_wait(lock._mutex, xt)) - return false; - } - - return true; - } - - private: - template - void do_wait(M& mutex) - { -#if defined(BOOST_HAS_WINTHREADS) - enter_wait(); -#endif - - typename M::cv_state state; - mutex.do_unlock(state); - -#if defined(BOOST_HAS_PTHREADS) - do_wait(state.pmutex); -#elif defined(BOOST_HAS_WINTHREADS) - do_wait(); -#endif - - mutex.do_lock(state); - } - - template - bool do_timed_wait(M& mutex, const xtime& xt) - { -#if defined(BOOST_HAS_WINTHREADS) - enter_wait(); -#endif - - typename M::cv_state state; - mutex.do_unlock(state); - - bool ret = false; - -#if defined(BOOST_HAS_PTHREADS) - ret = do_timed_wait(xt, state.pmutex); -#elif defined(BOOST_HAS_WINTHREADS) - ret = do_timed_wait(xt); -#endif - - mutex.do_lock(state); - - return ret; - } - -#if defined(BOOST_HAS_WINTHREADS) - void enter_wait(); - void do_wait(); - bool do_timed_wait(const xtime& xt); -#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) - unsigned long _gate; - unsigned long _queue; - unsigned long _mutex; - unsigned _gone; // # threads that timed out and never made it to the _queue - long _blocked; // # threads _blocked _waiting for the condition - unsigned _waiting; // # threads _waiting no longer _waiting for the condition but still - // _waiting to be removed from the _queue -#elif defined(BOOST_HAS_PTHREADS) - pthread_cond_t _cond; -#endif - }; -} // namespace boost - -#endif // BOOST_CONDITION_HPP diff --git a/include/boost/thread/config.hpp b/include/boost/thread/config.hpp deleted file mode 100644 index fe82f424..00000000 --- a/include/boost/thread/config.hpp +++ /dev/null @@ -1,65 +0,0 @@ -// This file is used to configure Boost.Threads during development -// in order to decouple dependency on any Boost release. Once -// accepted into Boost these contents will be moved to -// or some other appropriate build configuration and all -// #include statements will be changed -// accordingly. - -#ifndef BOOST_THREAD_CONFIG_HPP -#define BOOST_THREAD_CONFIG_HPP - -#include - -// Define if threading support is enabled for the toolset. -#undef BOOST_HAS_THREADS - -// Define if threading should be implemented in terms of Win32 threads. -#undef BOOST_HAS_WINTHREADS - -// Define if threading should be implemented in terms of POSIX threads. -#undef BOOST_HAS_PTHREADS - -// Define if BOOST_HAS_PTHREADS and pthread_delay_np() exists. -#undef BOOST_HAS_PTHREAD_DELAY_NP - -// Define if BOOST_HAS_PTHREADS and not BOOST_HAS_PTHREAD_DELAY_NP -// but nanosleep can be used instead. -#undef BOOST_HAS_NANOSLEEP - -// Define if BOOST_HAS_PTHREADS and pthread_yield() exists. -#undef BOOST_HAS_PTHREAD_YIELD - -// Define if BOOST_HAS_PTHREADS and not BOOST_HAS_PTHREAD_YIELD and -// sched_yield() exists. -#undef BOOST_HAS_SCHED_YIELD - -// Define if gettimeofday() exists. -#undef BOOST_HAS_GETTIMEOFDAY - -// Define if not BOOST_HAS_GETTIMEOFDAY and clock_gettime() exists. -#undef BOOST_HAS_CLOCK_GETTIME - -// Define if not BOOST_HAS_GETTIMEOFDAY and not BOOST_HAS_CLOCK_GETTIME and -// GetSystemTimeAsFileTime() can be called with an FTIME structure. -#undef BOOST_HAS_FTIME - -// Define if pthread_mutexattr_settype and pthread_mutexattr_gettype exist. -#undef BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE - -// Here we'll set up known compiler options. - -#if defined(BOOST_MSVC) -# if defined(_MT) -# define BOOST_HAS_THREADS -# endif -//# define BOOST_HAS_WINTHREADS // comment out this to test pthreads-win32. -# if !defined(BOOST_HAS_WINTHREADS) -# define BOOST_HAS_PTHREADS -# define BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE -# define PtW32NoCatchWarn -# pragma comment(lib, "pthreadVCE.lib") -# endif -# define BOOST_HAS_FTIME -#endif - -#endif \ No newline at end of file diff --git a/include/boost/thread/mutex.hpp b/include/boost/thread/mutex.hpp deleted file mode 100644 index 7e9d3ece..00000000 --- a/include/boost/thread/mutex.hpp +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (C) 2001 - * William E. Kempf - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. William E. Kempf makes no representations - * about the suitability of this software for any purpose. - * It is provided "as is" without express or implied warranty. - * - * Revision History (excluding minor changes for specific compilers) - * 8 Feb 01 Initial version. - * 22 May 01 Modified to use xtime for time outs. Factored out - * to three classes, mutex, try_mutex and timed_mutex. - */ - -#ifndef BOOST_MUTEX_HPP -#define BOOST_MUTEX_HPP - -#include -#ifndef BOOST_HAS_THREADS -# error Thread support is unavailable! -#endif - -#include -#include -#include - -#if defined(BOOST_HAS_PTHREADS) -# include -#endif - -namespace boost -{ - class condition; - - class mutex : private noncopyable - { - public: - friend class basic_lock; - friend class condition; - - typedef basic_lock lock; - - mutex(); - ~mutex(); - - private: -#if defined(BOOST_HAS_WINTHREADS) - typedef void* cv_state; -#elif defined(BOOST_HAS_PTHREADS) - struct cv_state - { - pthread_mutex_t* pmutex; - }; -#endif - void do_lock(); - void do_unlock(); - void do_lock(cv_state& state); - void do_unlock(cv_state& state); - -#if defined(BOOST_HAS_WINTHREADS) - unsigned long _mutex; -#elif defined(BOOST_HAS_PTHREADS) - pthread_mutex_t _mutex; -#endif - }; - - class try_mutex : private noncopyable - { - public: - friend class basic_lock; - friend class basic_trylock; - friend class condition; - - typedef basic_lock lock; - typedef basic_trylock trylock; - - try_mutex(); - ~try_mutex(); - - private: -#if defined(BOOST_HAS_WINTHREADS) - typedef void* cv_state; -#elif defined(BOOST_HAS_PTHREADS) - struct cv_state - { - pthread_mutex_t* pmutex; - }; -#endif - void do_lock(); - bool do_trylock(); - void do_unlock(); - void do_lock(cv_state& state); - void do_unlock(cv_state& state); - -#if defined(BOOST_HAS_WINTHREADS) - unsigned long _mutex; -#elif defined(BOOST_HAS_PTHREADS) - pthread_mutex_t _mutex; -#endif - }; - - class timed_mutex : private noncopyable - { - public: - friend class basic_lock; - friend class basic_trylock; - friend class basic_timedlock; - friend class condition; - - typedef basic_lock lock; - typedef basic_trylock trylock; - typedef basic_timedlock timedlock; - - timed_mutex(); - ~timed_mutex(); - - private: -#if defined(BOOST_HAS_WINTHREADS) - typedef void* cv_state; -#elif defined(BOOST_HAS_PTHREADS) - struct cv_state - { - pthread_mutex_t* pmutex; - }; -#endif - void do_lock(); - bool do_trylock(); - 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) - unsigned long _mutex; -#elif defined(BOOST_HAS_PTHREADS) - pthread_mutex_t _mutex; - pthread_cond_t _cond; - bool _locked; -#endif - }; -} // namespace boost - -#endif // BOOST_MUTEX_HPP diff --git a/include/boost/thread/recursive_mutex.hpp b/include/boost/thread/recursive_mutex.hpp deleted file mode 100644 index f44bf131..00000000 --- a/include/boost/thread/recursive_mutex.hpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (C) 2001 - * William E. Kempf - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. William E. Kempf makes no representations - * about the suitability of this software for any purpose. - * It is provided "as is" without express or implied warranty. - * - * Revision History (excluding minor changes for specific compilers) - * 8 Feb 01 Initial version. - * 1 Jun 01 Modified to use xtime for time outs. Factored out - * to three classes, mutex, try_mutex and timed_mutex. - * 11 Jun 01 Modified to use PTHREAD_MUTEX_RECURSIVE if available. - */ - -#ifndef BOOST_RECURSIVE_MUTEX_HPP -#define BOOST_RECURSIVE_MUTEX_HPP - -#include -#ifndef BOOST_HAS_THREADS -# error Thread support is unavailable! -#endif - -#include -#include - -#if defined(BOOST_HAS_PTHREADS) -# include -#endif - -namespace boost -{ - class condition; - - class recursive_mutex : private noncopyable - { - public: - friend class basic_lock; - friend class condition; - - typedef basic_lock lock; - - recursive_mutex(); - ~recursive_mutex(); - - private: -#if defined(BOOST_HAS_WINTHREADS) - typedef size_t cv_state; -#elif defined(BOOST_HAS_PTHREADS) - struct cv_state - { - long count; - pthread_mutex_t* pmutex; - }; -#endif - void do_lock(); - void do_unlock(); - void do_lock(cv_state& state); - void do_unlock(cv_state& state); - -#if defined(BOOST_HAS_WINTHREADS) - unsigned long _mutex; - unsigned long _count; -#elif defined(BOOST_HAS_PTHREADS) - pthread_mutex_t _mutex; - unsigned _count; -# if !defined(BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE) - pthread_cond_t _unlocked; - pthread_t _thread_id; - bool _valid_id; -# endif -#endif - }; - - class recursive_try_mutex : private noncopyable - { - public: - friend class basic_lock; - friend class basic_trylock; - friend class condition; - - typedef basic_lock lock; - typedef basic_trylock trylock; - - recursive_try_mutex(); - ~recursive_try_mutex(); - - private: -#if defined(BOOST_HAS_WINTHREADS) - typedef size_t cv_state; -#elif defined(BOOST_HAS_PTHREADS) - struct cv_state - { - long count; - pthread_mutex_t* pmutex; - }; -#endif - void do_lock(); - bool do_trylock(); - void do_unlock(); - void do_lock(cv_state& state); - void do_unlock(cv_state& state); - -#if defined(BOOST_HAS_WINTHREADS) - unsigned long _mutex; - unsigned long _count; -#elif defined(BOOST_HAS_PTHREADS) - pthread_mutex_t _mutex; - unsigned _count; -# if !defined(BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE) - pthread_cond_t _unlocked; - pthread_t _thread_id; - bool _valid_id; -# endif -#endif - }; - - class recursive_timed_mutex : private noncopyable - { - public: - friend class basic_lock; - friend class basic_trylock; - friend class basic_timedlock; - friend class condition; - - typedef basic_lock lock; - typedef basic_trylock trylock; - typedef basic_timedlock timedlock; - - recursive_timed_mutex(); - ~recursive_timed_mutex(); - - private: -#if defined(BOOST_HAS_WINTHREADS) - typedef size_t cv_state; -#elif defined(BOOST_HAS_PTHREADS) - struct cv_state - { - long count; - pthread_mutex_t* pmutex; - }; -#endif - void do_lock(); - bool do_trylock(); - 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) - unsigned long _mutex; - unsigned long _count; -#elif defined(BOOST_HAS_PTHREADS) - pthread_mutex_t _mutex; - pthread_cond_t _unlocked; - pthread_t _thread_id; - bool _valid_id; - unsigned _count; -#endif - }; -} // namespace boost - -#endif // BOOST_RECURSIVE_MUTEX_HPP diff --git a/include/boost/thread/semaphore.hpp b/include/boost/thread/semaphore.hpp deleted file mode 100644 index 773e6e8a..00000000 --- a/include/boost/thread/semaphore.hpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * Copyright (C) 2001 - * William E. Kempf - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. William E. Kempf makes no representations - * about the suitability of this software for any purpose. - * It is provided "as is" without express or implied warranty. - * - * Revision History (excluding minor changes for specific compilers) - * 8 Feb 01 Initial version. - * 22 May 01 Modified to use xtime for time outs. - */ - -#ifndef BOOST_SEMAPHORE_HPP -#define BOOST_SEMAPHORE_HPP - -#include -#ifndef BOOST_HAS_THREADS -# error Thread support is unavailable! -#endif - -#include -#include - -#if defined(BOOST_HAS_PTHREADS) -# include -#endif - -namespace boost { - class semaphore : private noncopyable - { - public: - explicit semaphore(unsigned count=0, unsigned max=0); - ~semaphore(); - - bool up(unsigned count=1, unsigned* prev=0); - void down(); - bool down(const xtime& xt); - - private: -#if defined(BOOST_HAS_WINTHREADS) - unsigned long _sema; -#elif defined(BOOST_HAS_PTHREADS) - pthread_mutex_t _mutex; - pthread_cond_t _cond; - unsigned _available; - unsigned _max; -#endif - }; -} // namespace boost - -#endif // BOOST_SEMAPHORE_HPP diff --git a/include/boost/thread/thread.hpp b/include/boost/thread/thread.hpp deleted file mode 100644 index 9920c073..00000000 --- a/include/boost/thread/thread.hpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2001 - * William E. Kempf - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. William E. Kempf makes no representations - * about the suitability of this software for any purpose. - * It is provided "as is" without express or implied warranty. - * - * Revision History (excluding minor changes for specific compilers) - * 8 Feb 01 Initial version. - * 1 Jun 01 Added boost::thread initial implementation. - */ - -#ifndef BOOST_THREAD_HPP -#define BOOST_THREAD_HPP - -#include -#ifndef BOOST_HAS_THREADS -# error Thread support is unavailable! -#endif - -#include -#include -#include - -#if defined(BOOST_HAS_PTHREADS) - struct timespec; -#endif - -namespace boost -{ - namespace detail - { - class thread_state; -// typedef function threadfunc; - typedef void (*threadfunc)(void* param); - } - - class lock_error : public std::runtime_error - { - public: - lock_error(); - }; - - class thread - { - public: - thread() : _state(0) { } - thread(const thread& other); - ~thread(); - - thread& operator=(const thread& other) - { - thread temp(other); - swap(temp); - return *this; - } - thread& swap(thread& other) - { - detail::thread_state* temp = other._state; - other._state = _state; - _state = temp; - return *this; - } - - bool operator==(const thread& other) { return _state == other._state; } - bool operator!=(const thread& other) { return _state != other._state; } - - bool is_alive() const; - void join(); - - static thread create(const detail::threadfunc& func, void* param=0); - static thread self(); - - static void join_all(); - static void sleep(const xtime& xt); - static void yield(); - - private: - detail::thread_state* _state; - }; -} // namespace boost - -#endif // BOOST_THREAD_HPP diff --git a/include/boost/thread/tss.hpp b/include/boost/thread/tss.hpp deleted file mode 100644 index a6c00370..00000000 --- a/include/boost/thread/tss.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2001 - * William E. Kempf - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. William E. Kempf makes no representations - * about the suitability of this software for any purpose. - * It is provided "as is" without express or implied warranty. - * - * Revision History (excluding minor changes for specific compilers) - * 6 Jun 01 Initial version. - */ - -#ifndef BOOST_TSS_HPP -#define BOOST_TSS_HPP - -#include -#ifndef BOOST_HAS_THREADS -# error Thread support is unavailable! -#endif - -#if defined(BOOST_HAS_PTHREADS) -# include -#endif - -namespace boost -{ - class tss - { - public: - tss(); - ~tss(); - - void* get() const; - bool set(void* value); - - private: -#if defined(BOOST_HAS_WINTHREADS) - unsigned long _key; -#elif defined(BOOST_HAS_PTHREADS) - pthread_key_t _key; -#endif - }; -} - -#endif // BOOST_TSS_HPP \ No newline at end of file diff --git a/include/boost/thread/xlock.hpp b/include/boost/thread/xlock.hpp deleted file mode 100644 index d97a82b7..00000000 --- a/include/boost/thread/xlock.hpp +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (C) 2001 - * William E. Kempf - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. William E. Kempf makes no representations - * about the suitability of this software for any purpose. - * It is provided "as is" without express or implied warranty. - * - * Revision History (excluding minor changes for specific compilers) - * 8 Feb 01 Initial version. - * 22 May 01 Modified to use xtime for time outs. - */ - -#ifndef BOOST_XLOCK_HPP -#define BOOST_XLOCK_HPP - -#include -#include -#include - -namespace boost { - class condition; - - template - class basic_lock : noncopyable - { - public: - friend class condition; - - typedef M mutex_type; - - explicit basic_lock(M& mx, bool lock_it=true) - : _mutex(mx), _locked(false) - { - if (lock_it) lock(); - } - ~basic_lock() - { - if (_locked) unlock(); - } - - void lock() - { - if (_locked) throw lock_error(); - _mutex.do_lock(); - _locked = true; - } - void unlock() - { - if (!_locked) throw lock_error(); - _mutex.do_unlock(); - _locked = false; - } - - operator const void*() const { return _locked ? this : 0; } - - private: - M& _mutex; - bool _locked; - }; - - template - class basic_trylock : private noncopyable - { - public: - friend class condition; - - typedef M mutex_type; - - explicit basic_trylock(M& mx) - : _mutex(mx), _locked(false) - { - try_lock(); - } - basic_trylock(M& mx, bool lock_it) - : _mutex(mx), _locked(false) - { - if (lock_it) lock(); - } - ~basic_trylock() - { - if (_locked) unlock(); - } - - void lock() - { - if (_locked) throw lock_error(); - _mutex.do_lock(); - _locked = true; - } - bool try_lock() - { - if (_locked) throw lock_error(); - return (_locked = _mutex.do_trylock()); - } - void unlock() - { - if (!_locked) throw lock_error(); - _mutex.do_unlock(); - _locked = false; - } - - operator const void*() const { return _locked ? this : 0; } - - private: - M& _mutex; - bool _locked; - }; - - template - class basic_timedlock : private noncopyable - { - public: - friend class condition; - - typedef M mutex_type; - - basic_timedlock(M& mx, const xtime& xt) - : _mutex(mx), _locked(false) - { - timed_lock(xt); - } - basic_timedlock(M& mx, bool lock_it) - : _mutex(mx), _locked(false) - { - if (lock_it) lock(); - } - ~basic_timedlock() - { - if (_locked) unlock(); - } - - void lock() - { - if (_locked) throw lock_error(); - _mutex.do_lock(); - _locked = true; - } - bool timed_lock(const xtime& xt) - { - if (_locked) throw lock_error(); - return (_locked = _mutex.do_timedlock(xt)); - } - void unlock() - { - if (!_locked) throw lock_error(); - _mutex.do_unlock(); - _locked = false; - } - - operator const void*() const { return _locked ? this : 0; } - - private: - M& _mutex; - bool _locked; - }; -} // namespace boost - -#endif // BOOST_XLOCK_HPP diff --git a/include/boost/thread/xtime.hpp b/include/boost/thread/xtime.hpp deleted file mode 100644 index b323640a..00000000 --- a/include/boost/thread/xtime.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2001 - * William E. Kempf - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. William E. Kempf makes no representations - * about the suitability of this software for any purpose. - * It is provided "as is" without express or implied warranty. - * - * Revision History (excluding minor changes for specific compilers) - * 8 Feb 01 Initial version. - */ - -#ifndef BOOST_XTIME_HPP -#define BOOST_XTIME_HPP - -#include - -namespace boost -{ - enum - { - TIME_UTC=1, - TIME_TAI, - TIME_MONOTONIC, - TIME_PROCESS, - TIME_THREAD, - TIME_LOCAL, - TIME_SYNC, - TIME_RESOLUTION - }; - - struct xtime - { -#if defined(BOOST_NO_INT64_T) - int_fast32_t sec; -#else - int_fast64_t sec; -#endif - int_fast32_t nsec; - }; - - int xtime_get(struct xtime* xtp, int clock_type); -} - -#endif // BOOST_XTIME_HPP \ No newline at end of file