LCOV - code coverage report
Current view: top level - salhelper/source - thread.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 11 18 61.1 %
Date: 2015-06-13 12:38:46 Functions: 5 6 83.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #include "sal/config.h"
      11             : 
      12             : #include <stdexcept>
      13             : #include <string>
      14             : 
      15             : #include "sal/log.hxx"
      16             : #include "salhelper/thread.hxx"
      17             : 
      18        7123 : salhelper::Thread::Thread(char const * name): name_(name) {}
      19             : 
      20        4783 : void salhelper::Thread::launch() {
      21             :     SAL_INFO("salhelper.thread", "launch " << name_);
      22             :     // Assumption is that osl::Thread::create returns normally with a true
      23             :     // return value iff it causes osl::Thread::run to start executing:
      24        4783 :     acquire();
      25             :     try {
      26        4783 :         if (!create()) {
      27           0 :             throw std::runtime_error("osl::Thread::create failed");
      28             :         }
      29           0 :     } catch (...) {
      30           0 :         release();
      31           0 :         throw;
      32             :     }
      33        4783 : }
      34             : 
      35        7116 : salhelper::Thread::~Thread() {}
      36             : 
      37        4783 : void salhelper::Thread::run() {
      38             :     try {
      39        4783 :         setName(name_);
      40        4783 :         execute();
      41           0 :     } catch (...) {
      42             :         // Work around the problem that onTerminated is not called if run throws
      43             :         // an exception:
      44           0 :         onTerminated();
      45           0 :         throw;
      46             :     }
      47        4781 : }
      48             : 
      49        4781 : void salhelper::Thread::onTerminated() { release(); }
      50             : 
      51             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11