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 : #include <sal/config.h>
21 :
22 : #include <osl/conditn.hxx>
23 :
24 : // include files of own module
25 : #include <helper/wakeupthread.hxx>
26 :
27 : namespace framework{
28 :
29 3856 : WakeUpThread::WakeUpThread(const css::uno::Reference< css::util::XUpdatable >& xListener)
30 3856 : : m_xListener (xListener)
31 : {
32 3856 : }
33 :
34 3842 : void SAL_CALL WakeUpThread::run()
35 : {
36 3842 : osl_setThreadName("framework::WakeUpThread");
37 :
38 3842 : ::osl::Condition aSleeper;
39 :
40 : TimeValue aTime;
41 3842 : aTime.Seconds = 0;
42 3842 : aTime.Nanosec = 25000000; // 25 msec
43 :
44 24420 : while(schedule())
45 : {
46 16736 : aSleeper.reset();
47 16736 : aSleeper.wait(&aTime);
48 :
49 16736 : css::uno::Reference< css::util::XUpdatable > xListener(m_xListener);
50 16736 : if (xListener.is())
51 16736 : xListener->update();
52 20578 : }
53 3842 : }
54 :
55 3842 : void SAL_CALL WakeUpThread::onTerminated()
56 : {
57 3842 : delete this;
58 3842 : }
59 :
60 : } // namespace framework
61 :
62 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|