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 : #ifndef __FRAMEWORK_HELPER_WAKEUPTHREAD_HXX_
21 : #define __FRAMEWORK_HELPER_WAKEUPTHREAD_HXX_
22 :
23 : //_______________________________________________
24 : // include files of own module
25 :
26 : #include <threadhelp/threadhelpbase.hxx>
27 : #include <macros/debug.hxx>
28 : #include <macros/generic.hxx>
29 :
30 : #include <general.h>
31 :
32 : //_______________________________________________
33 : // include UNO interfaces
34 :
35 : #include <com/sun/star/util/XUpdatable.hpp>
36 :
37 : //_______________________________________________
38 : // include all others
39 : #include <cppuhelper/weakref.hxx>
40 : #include <osl/thread.hxx>
41 :
42 :
43 : namespace framework{
44 :
45 :
46 : //===============================================
47 : /** @short implements a "sleeping" thread, which try to sleep
48 : without a using cpu consumption :-) */
49 284 : class WakeUpThread : public ThreadHelpBase
50 : , public ::osl::Thread
51 : {
52 : //-------------------------------------------
53 : // member
54 : private:
55 :
56 : /** @short this listener will be notified if this thread
57 : waked up. */
58 : css::uno::WeakReference< css::util::XUpdatable > m_xListener;
59 :
60 : //-------------------------------------------
61 : // interface
62 : public:
63 :
64 : /** @short Register a new listener on this thread.
65 :
66 : @descr The listener is holded as a weak reference.
67 : If the thread detects, that no listener exists ...
68 : he will terminate itself.
69 : */
70 : WakeUpThread(const css::uno::Reference< css::util::XUpdatable >& xListener);
71 :
72 : /** @descr The thread waits on a condition using a fix timeout value.
73 : If the thread wakes up he notify the internal set listener.
74 : The listener can use this "timeout" info for it's own purpose.
75 : The thread itself will wait on the condition again.
76 : */
77 : virtual void SAL_CALL run();
78 :
79 : virtual void SAL_CALL onTerminated();
80 : };
81 :
82 : } // namespace framework
83 :
84 : #endif // __FRAMEWORK_HELPER_WAKEUPTHREAD_HXX_
85 :
86 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|