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