LCOV - code coverage report
Current view: top level - libreoffice/vcl/source/helper - threadex.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 31 0.0 %
Date: 2012-12-27 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             : 
      21             : #define THREADEX_IMPLEMENTATION
      22             : #include <vcl/threadex.hxx>
      23             : #include <vcl/svapp.hxx>
      24             : 
      25             : using namespace vcl;
      26             : 
      27           0 : SolarThreadExecutor::SolarThreadExecutor()
      28             :     :m_nReturn( 0 )
      29           0 :     ,m_bTimeout( false )
      30             : {
      31           0 :     m_aStart = osl_createCondition();
      32           0 :     m_aFinish = osl_createCondition();
      33           0 : }
      34             : 
      35           0 : SolarThreadExecutor::~SolarThreadExecutor()
      36             : {
      37           0 :     osl_destroyCondition( m_aStart );
      38           0 :     osl_destroyCondition( m_aFinish );
      39           0 : }
      40             : 
      41           0 : IMPL_LINK_NOARG(SolarThreadExecutor, worker)
      42             : {
      43           0 :     if ( !m_bTimeout )
      44             :     {
      45           0 :         osl_setCondition( m_aStart );
      46           0 :         m_nReturn = doIt();
      47           0 :         osl_setCondition( m_aFinish );
      48             :     }
      49           0 :     return m_nReturn;
      50             : }
      51             : 
      52           0 : long SolarThreadExecutor::impl_execute( const TimeValue* _pTimeout )
      53             : {
      54           0 :     if( ::osl::Thread::getCurrentIdentifier() == Application::GetMainThreadIdentifier() )
      55             :     {
      56           0 :         osl_setCondition( m_aStart );
      57           0 :         m_nReturn = doIt();
      58           0 :         osl_setCondition( m_aFinish );
      59             :     }
      60             :     else
      61             :     {
      62           0 :         osl_resetCondition( m_aStart );
      63           0 :         osl_resetCondition( m_aFinish );
      64           0 :         sal_uLong nSolarMutexCount = Application::ReleaseSolarMutex();
      65           0 :         sal_uLong nEvent = Application::PostUserEvent( LINK( this, SolarThreadExecutor, worker ) );
      66           0 :         if ( osl_cond_result_timeout == osl_waitCondition( m_aStart, _pTimeout ) )
      67             :         {
      68           0 :             m_bTimeout = true;
      69           0 :             Application::RemoveUserEvent( nEvent );
      70             :         }
      71             :         else
      72           0 :             osl_waitCondition( m_aFinish, NULL );
      73           0 :         if( nSolarMutexCount )
      74           0 :             Application::AcquireSolarMutex( nSolarMutexCount );
      75             :     }
      76           0 :     return m_nReturn;
      77             : }
      78             : 
      79             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10