1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef __FRAMEWORK_HELPER_WAKEUPTHREAD_HXX_
29 #define __FRAMEWORK_HELPER_WAKEUPTHREAD_HXX_
30 
31 //_______________________________________________
32 // include files of own module
33 
34 #include <threadhelp/threadhelpbase.hxx>
35 #include <macros/debug.hxx>
36 #include <macros/generic.hxx>
37 
38 #ifndef __FRAMEWORK_GENERAL_HXX_
39 #include <general.h>
40 #endif
41 
42 //_______________________________________________
43 // include UNO interfaces
44 
45 #ifndef _COM_SUN_STAR_URTIL_XUPDATABLE_HPP_
46 #include <com/sun/star/util/XUpdatable.hpp>
47 #endif
48 
49 //_______________________________________________
50 // include all others
51 #include <cppuhelper/weakref.hxx>
52 #include <osl/thread.hxx>
53 
54 //_______________________________________________
55 // namespace
56 
57 namespace framework{
58 
59 //_______________________________________________
60 // definitions
61 
62 //===============================================
63 /** @short  implements a "sleeping" thread, which try to sleep
64             without a using cpu consumption :-) */
65 class WakeUpThread : public ThreadHelpBase
66                    , public ::osl::Thread
67 {
68     //-------------------------------------------
69     // member
70     private:
71 
72         /** @short  this listener will be notified if this thread
73                     waked up. */
74         css::uno::WeakReference< css::util::XUpdatable > m_xListener;
75 
76     //-------------------------------------------
77     // interface
78     public:
79 
80         /** @short  Register a new listener on this thread.
81 
82             @descr  The listener is holded as a weak reference.
83                     If the thread detects, that no listener exists ...
84                     he will terminate itself.
85          */
86         WakeUpThread(const css::uno::Reference< css::util::XUpdatable >& xListener);
87 
88         /** @descr  The thread waits on a condition using a fix timeout value.
89                     If the thread wakes up he notify the internal set listener.
90                     The listener can use this "timeout" info for it's own purpose.
91                     The thread itself will wait on the condition again.
92          */
93         virtual void SAL_CALL run();
94 
95         virtual void SAL_CALL onTerminated();
96 };
97 
98 } // namespace framework
99 
100 #endif // __FRAMEWORK_HELPER_WAKEUPTHREAD_HXX_
101