LCOV - code coverage report
Current view: top level - lunchbox - threadID.cpp (source / functions) Hit Total Coverage
Test: Lunchbox Lines: 19 24 79.2 %
Date: 2018-10-03 05:33:11 Functions: 8 10 80.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2010-2013, Stefan Eilemann <eile@eyescale.ch>
       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             : #include "threadID.h"
      19             : 
      20             : #include "log.h"
      21             : 
      22             : #include <cstring> // for memset
      23             : #include <pthread.h>
      24             : 
      25             : #include "detail/threadID.h"
      26             : 
      27             : namespace lunchbox
      28             : {
      29     4340742 : ThreadID::ThreadID()
      30     4340742 :     : _impl(new detail::ThreadID)
      31             : {
      32     4747699 :     memset(&_impl->pthread, 0, sizeof(pthread_t));
      33     4747699 : }
      34             : 
      35        1408 : ThreadID::ThreadID(const ThreadID& from)
      36        1408 :     : _impl(new detail::ThreadID)
      37             : {
      38        1408 :     _impl->pthread = from._impl->pthread;
      39        1408 : }
      40             : 
      41     9871021 : ThreadID::~ThreadID()
      42             : {
      43     4814066 :     delete _impl;
      44     5056955 : }
      45             : 
      46     2118371 : ThreadID& ThreadID::operator=(const ThreadID& from)
      47             : {
      48     2118371 :     _impl->pthread = from._impl->pthread;
      49     2118371 :     return *this;
      50             : }
      51             : 
      52     2971546 : bool ThreadID::operator==(const ThreadID& rhs) const
      53             : {
      54     2971546 :     return pthread_equal(_impl->pthread, rhs._impl->pthread);
      55             : }
      56             : 
      57           0 : bool ThreadID::operator!=(const ThreadID& rhs) const
      58             : {
      59           0 :     return !pthread_equal(_impl->pthread, rhs._impl->pthread);
      60             : }
      61             : 
      62        9736 : bool ThreadID::operator<(const ThreadID& rhs) const
      63             : {
      64             : #ifdef PTW32_VERSION
      65             :     return _impl->pthread.p < rhs._impl->pthread.p;
      66             : #else
      67        9736 :     return _impl->pthread < rhs._impl->pthread;
      68             : #endif
      69             : }
      70             : 
      71           0 : std::ostream& operator<<(std::ostream& os, const ThreadID& threadID)
      72             : {
      73             : #ifdef PTW32_VERSION
      74             :     os << threadID._impl->pthread.p;
      75             : #else
      76           0 :     os << threadID._impl->pthread;
      77             : #endif
      78           0 :     return os;
      79             : }
      80          75 : }

Generated by: LCOV version 1.11