Update ooo320-m1
[ooovba.git] / dbaccess / inc / AsyncronousLink.hxx
blobb367d694c7891731e73bb48d97982b88424f2467
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AsyncronousLink.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef DBAUI_ASYNCRONOUSLINK_HXX
32 #define DBAUI_ASYNCRONOUSLINK_HXX
34 #include <tools/link.hxx>
35 #include <osl/mutex.hxx>
37 namespace dbaui
39 // =========================================================================
40 // a helper for multi-threaded handling of async events
41 // -------------------------------------------------------------------------
42 /** handles asynchronous links which may be called in multi-threaded environments
43 If you use an instance of this class as member of your own class, it will handle
44 several crucial points for you (for instance the case that somebody posts the
45 event while another thread tries to delete this event in the _destructor_ of the
46 class).
48 class OAsyncronousLink
50 Link m_aHandler;
52 protected:
53 ::osl::Mutex m_aEventSafety;
54 ::osl::Mutex m_aDestructionSafety;
55 ULONG m_nEventId;
57 public:
58 /** constructs the object
59 @param _rHandler The link to be called asyncronously
61 OAsyncronousLink( const Link& _rHandler );
62 virtual ~OAsyncronousLink();
64 bool IsRunning() const { return m_nEventId != 0; }
66 void Call( void* _pArgument = NULL );
67 void CancelCall();
69 protected:
70 DECL_LINK(OnAsyncCall, void*);
73 #endif // DBAUI_ASYNCRONOUSLINK_HXX