Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-20 09:00:44

0001 #ifndef BOOST_SMART_PTR_DETAIL_LIGHTWEIGHT_THREAD_HPP_INCLUDED
0002 #define BOOST_SMART_PTR_DETAIL_LIGHTWEIGHT_THREAD_HPP_INCLUDED
0003 
0004 // MS compatible compilers support #pragma once
0005 
0006 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
0007 # pragma once
0008 #endif
0009 
0010 //  boost/detail/lightweight_thread.hpp
0011 //
0012 //  Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
0013 //  Copyright (c) 2008, 2018 Peter Dimov
0014 //
0015 //  Distributed under the Boost Software License, Version 1.0.
0016 //  See accompanying file LICENSE_1_0.txt or copy at
0017 //  http://www.boost.org/LICENSE_1_0.txt
0018 //
0019 //
0020 //  typedef /*...*/ lw_thread_t; // as pthread_t
0021 //  template<class F> int lw_thread_create( lw_thread_t & th, F f );
0022 //  void lw_thread_join( lw_thread_t th );
0023 
0024 #include <thread>
0025 #include <exception>
0026 
0027 namespace boost
0028 {
0029 namespace detail
0030 {
0031 
0032 using lw_thread_t = std::thread*;
0033 
0034 template<class F> int lw_thread_create( lw_thread_t& th, F f )
0035 {
0036     try
0037     {
0038         th = new std::thread( f );
0039         return 0;
0040     }
0041     catch( std::exception const& )
0042     {
0043         return -1;
0044     }
0045 }
0046 
0047 void lw_thread_join( lw_thread_t th )
0048 {
0049     th->join();
0050     delete th;
0051 }
0052 
0053 } // namespace detail
0054 } // namespace boost
0055 
0056 #endif // #ifndef BOOST_SMART_PTR_DETAIL_LIGHTWEIGHT_THREAD_HPP_INCLUDED