LCOV - code coverage report
Current view: top level - lunchbox - perThread.ipp (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 15 15 100.0 %
Date: 2014-08-05 Functions: 12 14 85.7 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2005-2013, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *
       4             :  * This library is free software; you can redistribute it and/or modify it under
       5             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       6             :  * by the Free Software Foundation.
       7             :  *
       8             :  * This library is distributed in the hope that it will be useful, but WITHOUT
       9             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      10             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      11             :  * details.
      12             :  *
      13             :  * You should have received a copy of the GNU Lesser General Public License
      14             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      15             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      16             :  */
      17             : 
      18             : namespace lunchbox
      19             : {
      20          32 : template< class T, void (*D)( T* ) > PerThread<T, D>::PerThread()
      21          32 :     : tls_( (TLS::ThreadDestructor_t)D )
      22          32 : {}
      23             : 
      24          29 : template< class T, void (*D)( T* ) > PerThread<T, D>::~PerThread()
      25          29 : {}
      26             : 
      27             : template< class T, void (*D)( T* ) >
      28       10042 : PerThread<T, D>& PerThread<T, D>::operator = ( const T* data )
      29             : {
      30       10042 :     tls_.set( static_cast< const void* >( data ));
      31       10042 :     return *this;
      32             : }
      33             : 
      34             : template< class T, void (*D)( T* ) >
      35        1024 : PerThread<T, D>& PerThread<T, D>::operator = ( const PerThread<T, D>& rhs )
      36             : {
      37        1024 :     tls_.set( rhs.tls_.get( ));
      38        1023 :     return *this;
      39             : }
      40             : 
      41       32024 : template< class T, void (*D)( T* ) > T* PerThread<T, D>::get()
      42             : {
      43       32024 :     return static_cast< T* >( tls_.get( ));
      44             : }
      45             : 
      46        1024 : template< class T, void (*D)( T* ) > const T* PerThread<T, D>::get() const
      47             : {
      48        1024 :     return static_cast< const T* >( tls_.get( ));
      49             : }
      50             : 
      51             : template< class T, void (*D)( T* ) > T* PerThread<T, D>::operator->()
      52             : {
      53             :     return static_cast< T* >( tls_.get( ));
      54             : }
      55             : 
      56             : template< class T, void (*D)( T* ) >
      57             : const T* PerThread<T, D>::operator->() const
      58             : {
      59             :     return static_cast< T* >( tls_.get( ));
      60             : }
      61             : 
      62             : template< class T, void (*D)( T* ) > bool PerThread<T, D>::operator ! () const
      63             : {
      64             :     return tls_.get() == 0;
      65             : }
      66             : 
      67             : template< class T, void (*D)( T* ) > bool PerThread<T, D>::isValid() const
      68             : {
      69             :     return tls_.get() != 0;
      70             : }
      71             : }

Generated by: LCOV version 1.10