sl@0: // Copyright (C) 2001-2003 sl@0: // William E. Kempf sl@0: // sl@0: // Distributed under the Boost Software License, Version 1.0. (See accompanying sl@0: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) sl@0: sl@0: #ifndef BOOST_THREAD_WEK070601_HPP sl@0: #define BOOST_THREAD_WEK070601_HPP sl@0: sl@0: #include sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #if defined(BOOST_HAS_PTHREADS) sl@0: # include sl@0: # include sl@0: #elif defined(BOOST_HAS_MPTASKS) sl@0: # include sl@0: #endif sl@0: sl@0: namespace boost { sl@0: sl@0: struct xtime; sl@0: // disable warnings about non dll import sl@0: // see: http://www.boost.org/more/separate_compilation.html#dlls sl@0: #ifdef BOOST_MSVC sl@0: # pragma warning(push) sl@0: # pragma warning(disable: 4251 4231 4660 4275) sl@0: #endif sl@0: class BOOST_THREAD_DECL thread : private noncopyable sl@0: { sl@0: public: sl@0: thread(); sl@0: explicit thread(const function0& threadfunc); sl@0: ~thread(); sl@0: sl@0: bool operator==(const thread& other) const; sl@0: bool operator!=(const thread& other) const; sl@0: sl@0: void join(); sl@0: sl@0: static void sleep(const xtime& xt); sl@0: static void yield(); sl@0: sl@0: private: sl@0: #if defined(BOOST_HAS_WINTHREADS) sl@0: void* m_thread; sl@0: unsigned int m_id; sl@0: #elif defined(BOOST_HAS_PTHREADS) sl@0: private: sl@0: pthread_t m_thread; sl@0: #elif defined(BOOST_HAS_MPTASKS) sl@0: MPQueueID m_pJoinQueueID; sl@0: MPTaskID m_pTaskID; sl@0: #endif sl@0: bool m_joinable; sl@0: }; sl@0: sl@0: class BOOST_THREAD_DECL thread_group : private noncopyable sl@0: { sl@0: public: sl@0: thread_group(); sl@0: ~thread_group(); sl@0: sl@0: thread* create_thread(const function0& threadfunc); sl@0: void add_thread(thread* thrd); sl@0: void remove_thread(thread* thrd); sl@0: void join_all(); sl@0: int size(); sl@0: sl@0: private: sl@0: std::list m_threads; sl@0: mutex m_mutex; sl@0: }; sl@0: #ifdef BOOST_MSVC sl@0: # pragma warning(pop) sl@0: #endif sl@0: } // namespace boost sl@0: sl@0: // Change Log: sl@0: // 8 Feb 01 WEKEMPF Initial version. sl@0: // 1 Jun 01 WEKEMPF Added boost::thread initial implementation. sl@0: // 3 Jul 01 WEKEMPF Redesigned boost::thread to be noncopyable. sl@0: sl@0: #endif // BOOST_THREAD_WEK070601_HPP