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