ossrv_pub/boost_apis/boost/thread/thread.hpp
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (C) 2001-2003
       
     2 // William E. Kempf
       
     3 //
       
     4 //  Distributed under the Boost Software License, Version 1.0. (See accompanying 
       
     5 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       
     6 
       
     7 #ifndef BOOST_THREAD_WEK070601_HPP
       
     8 #define BOOST_THREAD_WEK070601_HPP
       
     9 
       
    10 #include <boost/thread/detail/config.hpp>
       
    11 
       
    12 #include <boost/utility.hpp>
       
    13 #include <boost/function.hpp>
       
    14 #include <boost/thread/mutex.hpp>
       
    15 #include <list>
       
    16 #include <memory>
       
    17 
       
    18 #if defined(BOOST_HAS_PTHREADS)
       
    19 #   include <pthread.h>
       
    20 #   include <boost/thread/condition.hpp>
       
    21 #elif defined(BOOST_HAS_MPTASKS)
       
    22 #   include <Multiprocessing.h>
       
    23 #endif
       
    24 
       
    25 namespace boost {
       
    26 
       
    27 struct xtime;
       
    28 // disable warnings about non dll import
       
    29 // see: http://www.boost.org/more/separate_compilation.html#dlls
       
    30 #ifdef BOOST_MSVC
       
    31 #   pragma warning(push)
       
    32 #   pragma warning(disable: 4251 4231 4660 4275)
       
    33 #endif
       
    34 class BOOST_THREAD_DECL thread : private noncopyable
       
    35 {
       
    36 public:
       
    37     thread();
       
    38     explicit thread(const function0<void>& threadfunc);
       
    39     ~thread();
       
    40 
       
    41     bool operator==(const thread& other) const;
       
    42     bool operator!=(const thread& other) const;
       
    43 
       
    44     void join();
       
    45 
       
    46     static void sleep(const xtime& xt);
       
    47     static void yield();
       
    48 
       
    49 private:
       
    50 #if defined(BOOST_HAS_WINTHREADS)
       
    51     void* m_thread;
       
    52     unsigned int m_id;
       
    53 #elif defined(BOOST_HAS_PTHREADS)
       
    54 private:
       
    55     pthread_t m_thread;
       
    56 #elif defined(BOOST_HAS_MPTASKS)
       
    57     MPQueueID m_pJoinQueueID;
       
    58     MPTaskID m_pTaskID;
       
    59 #endif
       
    60     bool m_joinable;
       
    61 };
       
    62 
       
    63 class BOOST_THREAD_DECL thread_group : private noncopyable
       
    64 {
       
    65 public:
       
    66     thread_group();
       
    67     ~thread_group();
       
    68 
       
    69     thread* create_thread(const function0<void>& threadfunc);
       
    70     void add_thread(thread* thrd);
       
    71     void remove_thread(thread* thrd);
       
    72     void join_all();
       
    73         int size();
       
    74 
       
    75 private:
       
    76     std::list<thread*> m_threads;
       
    77     mutex m_mutex;
       
    78 };
       
    79 #ifdef BOOST_MSVC
       
    80 #   pragma warning(pop)
       
    81 #endif
       
    82 } // namespace boost
       
    83 
       
    84 // Change Log:
       
    85 //    8 Feb 01  WEKEMPF Initial version.
       
    86 //    1 Jun 01  WEKEMPF Added boost::thread initial implementation.
       
    87 //    3 Jul 01  WEKEMPF Redesigned boost::thread to be noncopyable.
       
    88 
       
    89 #endif // BOOST_THREAD_WEK070601_HPP