LCOV - code coverage report
Current view: top level - libreoffice/dbaccess/source/ui/browser - AsyncronousLink.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 32 0.0 %
Date: 2012-12-27 Functions: 0 7 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 "AsyncronousLink.hxx"
      21             : #include <vcl/svapp.hxx>
      22             : #include <tools/debug.hxx>
      23             : 
      24             : //==================================================================
      25             : //= OAsyncronousLink
      26             : //==================================================================
      27             : using namespace dbaui;
      28             : DBG_NAME(OAsyncronousLink)
      29             : //------------------------------------------------------------------
      30           0 : OAsyncronousLink::OAsyncronousLink( const Link& _rHandler )
      31             :     :m_aHandler(_rHandler)
      32             :     ,m_aEventSafety()
      33             :     ,m_aDestructionSafety()
      34           0 :     ,m_nEventId(0)
      35             : {
      36             :     DBG_CTOR(OAsyncronousLink,NULL);
      37           0 : }
      38             : 
      39             : //------------------------------------------------------------------
      40           0 : OAsyncronousLink::~OAsyncronousLink()
      41             : {
      42             :     {
      43           0 :         ::osl::MutexGuard aEventGuard( m_aEventSafety );
      44           0 :         if ( m_nEventId )
      45           0 :             Application::RemoveUserEvent(m_nEventId);
      46           0 :         m_nEventId = 0;
      47             :     }
      48             : 
      49             :     {
      50           0 :         ::osl::MutexGuard aDestructionGuard( m_aDestructionSafety );
      51             :         // this is just for the case we're deleted while another thread just handled the event :
      52             :         // if this other thread called our link while we were deleting the event here, the
      53             :         // link handler blocked. With leaving the above block it continued, but now we are prevented
      54             :         // to leave this destructor 'til the link handler recognizes that nEvent == 0 and leaves.
      55             :     }
      56             :     DBG_DTOR(OAsyncronousLink,NULL);
      57           0 : }
      58             : 
      59             : 
      60             : //------------------------------------------------------------------
      61           0 : void OAsyncronousLink::Call( void* _pArgument )
      62             : {
      63           0 :     ::osl::MutexGuard aEventGuard( m_aEventSafety );
      64           0 :     if (m_nEventId)
      65           0 :         Application::RemoveUserEvent(m_nEventId);
      66           0 :     m_nEventId = Application::PostUserEvent( LINK( this, OAsyncronousLink, OnAsyncCall ), _pArgument );
      67           0 : }
      68             : 
      69             : //------------------------------------------------------------------
      70           0 : void OAsyncronousLink::CancelCall()
      71             : {
      72           0 :     ::osl::MutexGuard aEventGuard( m_aEventSafety );
      73           0 :     if ( m_nEventId )
      74           0 :         Application::RemoveUserEvent( m_nEventId );
      75           0 :     m_nEventId = 0;
      76           0 : }
      77             : 
      78             : //------------------------------------------------------------------
      79           0 : IMPL_LINK(OAsyncronousLink, OnAsyncCall, void*, _pArg)
      80             : {
      81             :     {
      82           0 :         ::osl::MutexGuard aDestructionGuard( m_aDestructionSafety );
      83             :         {
      84           0 :             ::osl::MutexGuard aEventGuard( m_aEventSafety );
      85           0 :             if (!m_nEventId)
      86             :                 // our destructor deleted the event just while we we're waiting for m_aEventSafety
      87             :                 // -> get outta here
      88           0 :                 return 0;
      89           0 :             m_nEventId = 0;
      90           0 :         }
      91             :     }
      92           0 :     if (m_aHandler.IsSet())
      93           0 :         return m_aHandler.Call(_pArg);
      94             : 
      95           0 :     return 0L;
      96             : }
      97             : 
      98             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10