LCOV - code coverage report
Current view: top level - lunchbox - perThread.ipp (source / functions) Hit Total Coverage
Test: Lunchbox Lines: 15 15 100.0 %
Date: 2018-10-03 05:33:11 Functions: 14 14 100.0 %

          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             : template <class T, void (*D)(T*)>
      21          25 : PerThread<T, D>::PerThread()
      22          25 :     : tls_((TLS::ThreadDestructor_t)D)
      23             : {
      24          25 : }
      25             : 
      26             : template <class T, void (*D)(T*)>
      27          25 : PerThread<T, D>::~PerThread()
      28             : {
      29          25 : }
      30             : 
      31             : template <class T, void (*D)(T*)>
      32        6386 : PerThread<T, D>& PerThread<T, D>::operator=(const T* data)
      33             : {
      34        6386 :     tls_.set(static_cast<const void*>(data));
      35        6386 :     return *this;
      36             : }
      37             : 
      38             : template <class T, void (*D)(T*)>
      39        1024 : PerThread<T, D>& PerThread<T, D>::operator=(const PerThread<T, D>& rhs)
      40             : {
      41        1024 :     tls_.set(rhs.tls_.get());
      42        1024 :     return *this;
      43             : }
      44             : 
      45             : template <class T, void (*D)(T*)>
      46       22619 : T* PerThread<T, D>::get()
      47             : {
      48       22619 :     return static_cast<T*>(tls_.get());
      49             : }
      50             : 
      51             : template <class T, void (*D)(T*)>
      52        1024 : const T* PerThread<T, D>::get() const
      53             : {
      54        1024 :     return static_cast<const T*>(tls_.get());
      55             : }
      56             : 
      57             : template <class T, void (*D)(T*)>
      58             : T* PerThread<T, D>::operator->()
      59             : {
      60             :     return static_cast<T*>(tls_.get());
      61             : }
      62             : 
      63             : template <class T, void (*D)(T*)>
      64             : const T* PerThread<T, D>::operator->() const
      65             : {
      66             :     return static_cast<T*>(tls_.get());
      67             : }
      68             : 
      69             : template <class T, void (*D)(T*)>
      70             : bool PerThread<T, D>::operator!() const
      71             : {
      72             :     return tls_.get() == 0;
      73             : }
      74             : 
      75             : template <class T, void (*D)(T*)>
      76             : bool PerThread<T, D>::isValid() const
      77             : {
      78             :     return tls_.get() != 0;
      79             : }
      80             : }

Generated by: LCOV version 1.11