source: NonGTP/Boost/boost/thread/thread.hpp @ 857

Revision 857, 2.2 KB checked in by igarcia, 19 years ago (diff)
Line 
1// Copyright (C) 2001-2003
2// William E. Kempf
3//
4// Permission to use, copy, modify, distribute and sell this software
5// and its documentation for any purpose is hereby granted without fee,
6// provided that the above copyright notice appear in all copies and
7// that both that copyright notice and this permission notice appear
8// in supporting documentation.  William E. Kempf makes no representations
9// about the suitability of this software for any purpose.
10// It is provided "as is" without express or implied warranty.
11
12#ifndef BOOST_THREAD_WEK070601_HPP
13#define BOOST_THREAD_WEK070601_HPP
14
15#include <boost/thread/detail/config.hpp>
16
17#include <boost/utility.hpp>
18#include <boost/function.hpp>
19#include <boost/thread/mutex.hpp>
20#include <list>
21#include <memory>
22
23#if defined(BOOST_HAS_PTHREADS)
24#   include <pthread.h>
25#   include <boost/thread/condition.hpp>
26#elif defined(BOOST_HAS_MPTASKS)
27#   include <Multiprocessing.h>
28#endif
29
30namespace boost {
31
32struct xtime;
33
34class BOOST_THREAD_DECL thread : private noncopyable
35{
36public:
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
49private:
50#if defined(BOOST_HAS_WINTHREADS)
51    void* m_thread;
52    unsigned int m_id;
53#elif defined(BOOST_HAS_PTHREADS)
54private:
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
63class BOOST_THREAD_DECL thread_group : private noncopyable
64{
65public:
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
75private:
76    std::list<thread*> m_threads;
77    mutex m_mutex;
78};
79
80} // namespace boost
81
82// Change Log:
83//    8 Feb 01  WEKEMPF Initial version.
84//    1 Jun 01  WEKEMPF Added boost::thread initial implementation.
85//    3 Jul 01  WEKEMPF Redesigned boost::thread to be noncopyable.
86
87#endif // BOOST_THREAD_WEK070601_HPP
Note: See TracBrowser for help on using the repository browser.