1*6d739b60SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*6d739b60SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*6d739b60SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*6d739b60SAndrew Rist  * distributed with this work for additional information
6*6d739b60SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*6d739b60SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*6d739b60SAndrew Rist  * "License"); you may not use this file except in compliance
9*6d739b60SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*6d739b60SAndrew Rist  *
11*6d739b60SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*6d739b60SAndrew Rist  *
13*6d739b60SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*6d739b60SAndrew Rist  * software distributed under the License is distributed on an
15*6d739b60SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*6d739b60SAndrew Rist  * KIND, either express or implied.  See the License for the
17*6d739b60SAndrew Rist  * specific language governing permissions and limitations
18*6d739b60SAndrew Rist  * under the License.
19*6d739b60SAndrew Rist  *
20*6d739b60SAndrew Rist  *************************************************************/
21*6d739b60SAndrew Rist 
22*6d739b60SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_framework.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //_______________________________________________
28cdf0e10cSrcweir // include files of own module
29cdf0e10cSrcweir #include <helper/wakeupthread.hxx>
30cdf0e10cSrcweir #include <threadhelp/readguard.hxx>
31cdf0e10cSrcweir #include <threadhelp/writeguard.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir //_______________________________________________
34cdf0e10cSrcweir // namespace
35cdf0e10cSrcweir 
36cdf0e10cSrcweir namespace framework{
37cdf0e10cSrcweir 
38cdf0e10cSrcweir //_______________________________________________
39cdf0e10cSrcweir // declarations
40cdf0e10cSrcweir 
41cdf0e10cSrcweir //***********************************************
WakeUpThread(const css::uno::Reference<css::util::XUpdatable> & xListener)42cdf0e10cSrcweir WakeUpThread::WakeUpThread(const css::uno::Reference< css::util::XUpdatable >& xListener)
43cdf0e10cSrcweir     : ThreadHelpBase(         )
44cdf0e10cSrcweir     , m_xListener   (xListener)
45cdf0e10cSrcweir {
46cdf0e10cSrcweir }
47cdf0e10cSrcweir 
48cdf0e10cSrcweir //***********************************************
run()49cdf0e10cSrcweir void SAL_CALL WakeUpThread::run()
50cdf0e10cSrcweir {
51cdf0e10cSrcweir     ::osl::Condition aSleeper;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir     TimeValue aTime;
54cdf0e10cSrcweir     aTime.Seconds = 0;
55cdf0e10cSrcweir     aTime.Nanosec = 25000000; // 25 msec
56cdf0e10cSrcweir 
57cdf0e10cSrcweir     while(schedule())
58cdf0e10cSrcweir     {
59cdf0e10cSrcweir         aSleeper.reset();
60cdf0e10cSrcweir         aSleeper.wait(&aTime);
61cdf0e10cSrcweir 
62cdf0e10cSrcweir         // SAFE ->
63cdf0e10cSrcweir         ReadGuard aReadLock(m_aLock);
64cdf0e10cSrcweir         css::uno::Reference< css::util::XUpdatable > xListener(m_xListener.get(), css::uno::UNO_QUERY);
65cdf0e10cSrcweir         aReadLock.unlock();
66cdf0e10cSrcweir         // <- SAFE
67cdf0e10cSrcweir 
68cdf0e10cSrcweir         if (xListener.is())
69cdf0e10cSrcweir             xListener->update();
70cdf0e10cSrcweir     }
71cdf0e10cSrcweir }
72cdf0e10cSrcweir 
73cdf0e10cSrcweir //***********************************************
onTerminated()74cdf0e10cSrcweir void SAL_CALL WakeUpThread::onTerminated()
75cdf0e10cSrcweir {
76cdf0e10cSrcweir     delete this;
77cdf0e10cSrcweir }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir } // namespace framework
80