boost::thread

提供: C++入門
2013年3月10日 (日) 12:26時点におけるDaemon (トーク | 投稿記録)による版 (ページの作成:「<!-- vim: filetype=mediawiki --> 読み方 ;boost thread: ぶーすと すれっど __TOC__ == 概要 == == インストール == <syntaxhighlight lang="bash...」)

(差分) ←前の版 | 最新版 (差分) | 次の版→ (差分)
移動: 案内検索
スポンサーリンク


読み方

boost thread
ぶーすと すれっど

概要

インストール

 

ヘッダファイル

#include <boost/thread.hpp>
#include <boost/thread/thread.hpp>
 
namespace boost
{
  class thread;
  void swap(thread& lhs,thread& rhs) noexcept;
 
  namespace this_thread
  {
    thread::id get_id() noexcept;
    template<typename TimeDuration>
    void yield() noexcept; // DEPRECATED
    template <class Clock, class Duration>
    void sleep_until(const chrono::time_point<Clock, Duration>& abs_time);
    template <class Rep, class Period>
    void sleep_for(const chrono::duration<Rep, Period>& rel_time);
 
    template<typename Callable>
    void at_thread_exit(Callable func); // EXTENSION
 
    void interruption_point(); // EXTENSION
    bool interruption_requested() noexcept; // EXTENSION
    bool interruption_enabled() noexcept; // EXTENSION 
    class disable_interruption; // EXTENSION
    class restore_interruption; // EXTENSION
 
  #if defined BOOST_THREAD_USES_DATETIME
    template <TimeDuration>
    void sleep(TimeDuration const& rel_time);  // DEPRECATED
    void sleep(system_time const& abs_time); // DEPRECATED
  #endif
  }
  class thread_group; // EXTENSION

boost_thread_1.cpp の例

ソースコード boost_thread_1.cpp

#include <boost/thread.hpp>
#include <iostream>
 
void
thread_1 () {
        std::cout << __PRETTY_FUNCTION__ << std::endl;
}
 
int
main(int argc, char const* argv[])
{
        boost::thread th1(thread_1);
 
        th1.join ();
 
        return 0;
}

コンパイル

g++ -I/usr/local/include -L/usr/local/lib -Lboost_thread boost_thread_1.cpp -o boost_thread_1

実行例

% ./boost_thread_1
void thread_1()


関連項目




スポンサーリンク