update dev300-m58
[ooovba.git] / framework / inc / helper / wakeupthread.hxx
blob47b0dd969b6a4603a1ef73990add30c05a3adeaf
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: wakeupthread.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 __FRAMEWORK_HELPER_WAKEUPTHREAD_HXX_
32 #define __FRAMEWORK_HELPER_WAKEUPTHREAD_HXX_
34 //_______________________________________________
35 // include files of own module
37 #include <threadhelp/threadhelpbase.hxx>
38 #include <macros/debug.hxx>
39 #include <macros/generic.hxx>
41 #ifndef __FRAMEWORK_GENERAL_HXX_
42 #include <general.h>
43 #endif
45 //_______________________________________________
46 // include UNO interfaces
48 #ifndef _COM_SUN_STAR_URTIL_XUPDATABLE_HPP_
49 #include <com/sun/star/util/XUpdatable.hpp>
50 #endif
52 //_______________________________________________
53 // include all others
54 #include <cppuhelper/weakref.hxx>
55 #include <osl/thread.hxx>
57 //_______________________________________________
58 // namespace
60 namespace framework{
62 //_______________________________________________
63 // definitions
65 //===============================================
66 /** @short implements a "sleeping" thread, which try to sleep
67 without a using cpu consumption :-) */
68 class WakeUpThread : public ThreadHelpBase
69 , public ::osl::Thread
71 //-------------------------------------------
72 // member
73 private:
75 /** @short this listener will be notified if this thread
76 waked up. */
77 css::uno::WeakReference< css::util::XUpdatable > m_xListener;
79 //-------------------------------------------
80 // interface
81 public:
83 /** @short Register a new listener on this thread.
85 @descr The listener is holded as a weak reference.
86 If the thread detects, that no listener exists ...
87 he will terminate itself.
89 WakeUpThread(const css::uno::Reference< css::util::XUpdatable >& xListener);
91 /** @descr The thread waits on a condition using a fix timeout value.
92 If the thread wakes up he notify the internal set listener.
93 The listener can use this "timeout" info for it's own purpose.
94 The thread itself will wait on the condition again.
96 virtual void SAL_CALL run();
98 virtual void SAL_CALL onTerminated();
101 } // namespace framework
103 #endif // __FRAMEWORK_HELPER_WAKEUPTHREAD_HXX_