LCOV - code coverage report
Current view: top level - usr/include/boost/thread - tss.hpp (source / functions) Hit Total Coverage
Test: ROSE Lines: 0 20 0.0 %
Date: 2022-12-08 13:48:47 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #ifndef BOOST_THREAD_TSS_HPP
       2             : #define BOOST_THREAD_TSS_HPP
       3             : // Distributed under the Boost Software License, Version 1.0. (See
       4             : // accompanying file LICENSE_1_0.txt or copy at
       5             : // http://www.boost.org/LICENSE_1_0.txt)
       6             : // (C) Copyright 2007-8 Anthony Williams
       7             : 
       8             : #include <boost/thread/detail/config.hpp>
       9             : 
      10             : #include <boost/type_traits/add_reference.hpp>
      11             : 
      12             : #include <boost/config/abi_prefix.hpp>
      13             : 
      14             : namespace boost
      15             : {
      16             :     namespace detail
      17             :     {
      18             :         namespace thread
      19             :         {
      20             :             typedef void(*cleanup_func_t)(void*);
      21             :             typedef void(*cleanup_caller_t)(cleanup_func_t, void*);
      22             :         }
      23             : 
      24             :         BOOST_THREAD_DECL void set_tss_data(void const* key,detail::thread::cleanup_caller_t caller,detail::thread::cleanup_func_t func,void* tss_data,bool cleanup_existing);
      25             :         BOOST_THREAD_DECL void* get_tss_data(void const* key);
      26             :     }
      27             : 
      28             :     template <typename T>
      29             :     class thread_specific_ptr
      30             :     {
      31             :     private:
      32             :         thread_specific_ptr(thread_specific_ptr&);
      33             :         thread_specific_ptr& operator=(thread_specific_ptr&);
      34             : 
      35             :         typedef void(*original_cleanup_func_t)(T*);
      36             : 
      37           0 :         static void default_deleter(T* data)
      38             :         {
      39           0 :             delete data;
      40           0 :         }
      41             : 
      42           0 :         static void cleanup_caller(detail::thread::cleanup_func_t cleanup_function,void* data)
      43             :         {
      44           0 :             reinterpret_cast<original_cleanup_func_t>(cleanup_function)(static_cast<T*>(data));
      45           0 :         }
      46             : 
      47             : 
      48             :         detail::thread::cleanup_func_t cleanup;
      49             : 
      50             :     public:
      51             :         typedef T element_type;
      52             : 
      53           0 :         thread_specific_ptr():
      54           0 :             cleanup(reinterpret_cast<detail::thread::cleanup_func_t>(&default_deleter))
      55             :         {}
      56             :         explicit thread_specific_ptr(void (*func_)(T*))
      57             :           : cleanup(reinterpret_cast<detail::thread::cleanup_func_t>(func_))
      58             :         {}
      59           0 :         ~thread_specific_ptr()
      60             :         {
      61           0 :             detail::set_tss_data(this,0,0,0,true);
      62           0 :         }
      63             : 
      64           0 :         T* get() const
      65             :         {
      66           0 :             return static_cast<T*>(detail::get_tss_data(this));
      67             :         }
      68             :         T* operator->() const
      69             :         {
      70             :             return get();
      71             :         }
      72           0 :         typename add_reference<T>::type operator*() const
      73             :         {
      74           0 :             return *get();
      75             :         }
      76             :         T* release()
      77             :         {
      78             :             T* const temp=get();
      79             :             detail::set_tss_data(this,0,0,0,false);
      80             :             return temp;
      81             :         }
      82           0 :         void reset(T* new_value=0)
      83             :         {
      84           0 :             T* const current_value=get();
      85           0 :             if(current_value!=new_value)
      86             :             {
      87           0 :                 detail::set_tss_data(this,&cleanup_caller,cleanup,new_value,true);
      88             :             }
      89           0 :         }
      90             :     };
      91             : }
      92             : 
      93             : #include <boost/config/abi_suffix.hpp>
      94             : 
      95             : #endif

Generated by: LCOV version 1.14