LCOV - code coverage report
Current view: top level - vcl/source/helper - threadex.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 31 0.0 %
Date: 2014-04-14 Functions: 0 6 0.0 %
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             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <vcl/threadex.hxx>
      21             : #include <vcl/svapp.hxx>
      22             : 
      23             : using namespace vcl;
      24             : 
      25           0 : SolarThreadExecutor::SolarThreadExecutor()
      26             :     :m_nReturn( 0 )
      27           0 :     ,m_bTimeout( false )
      28             : {
      29           0 :     m_aStart = osl_createCondition();
      30           0 :     m_aFinish = osl_createCondition();
      31           0 : }
      32             : 
      33           0 : SolarThreadExecutor::~SolarThreadExecutor()
      34             : {
      35           0 :     osl_destroyCondition( m_aStart );
      36           0 :     osl_destroyCondition( m_aFinish );
      37           0 : }
      38             : 
      39           0 : IMPL_LINK_NOARG(SolarThreadExecutor, worker)
      40             : {
      41           0 :     if ( !m_bTimeout )
      42             :     {
      43           0 :         osl_setCondition( m_aStart );
      44           0 :         m_nReturn = doIt();
      45           0 :         osl_setCondition( m_aFinish );
      46             :     }
      47           0 :     return m_nReturn;
      48             : }
      49             : 
      50           0 : long SolarThreadExecutor::impl_execute( const TimeValue* _pTimeout )
      51             : {
      52           0 :     if( ::osl::Thread::getCurrentIdentifier() == Application::GetMainThreadIdentifier() )
      53             :     {
      54           0 :         osl_setCondition( m_aStart );
      55           0 :         m_nReturn = doIt();
      56           0 :         osl_setCondition( m_aFinish );
      57             :     }
      58             :     else
      59             :     {
      60           0 :         osl_resetCondition( m_aStart );
      61           0 :         osl_resetCondition( m_aFinish );
      62           0 :         sal_uLong nSolarMutexCount = Application::ReleaseSolarMutex();
      63           0 :         sal_uLong nEvent = Application::PostUserEvent( LINK( this, SolarThreadExecutor, worker ) );
      64           0 :         if ( osl_cond_result_timeout == osl_waitCondition( m_aStart, _pTimeout ) )
      65             :         {
      66           0 :             m_bTimeout = true;
      67           0 :             Application::RemoveUserEvent( nEvent );
      68             :         }
      69             :         else
      70           0 :             osl_waitCondition( m_aFinish, NULL );
      71           0 :         if( nSolarMutexCount )
      72           0 :             Application::AcquireSolarMutex( nSolarMutexCount );
      73             :     }
      74           0 :     return m_nReturn;
      75             : }
      76             : 
      77             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10