Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
017f2507
Kaydet (Commit)
017f2507
authored
Nis 22, 2015
tarafından
Stephan Bergmann
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Ensure WakeUpThread is joined before exit
Change-Id: If50fe94875b29043c75b581bf39ca9deea59dbe3
üst
deaed8af
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
78 deletions
+52
-78
statusindicatorfactory.hxx
framework/inc/helper/statusindicatorfactory.hxx
+1
-1
wakeupthread.hxx
framework/inc/helper/wakeupthread.hxx
+21
-40
statusindicatorfactory.cxx
framework/source/helper/statusindicatorfactory.cxx
+3
-7
wakeupthread.cxx
framework/source/helper/wakeupthread.cxx
+27
-30
No files found.
framework/inc/helper/statusindicatorfactory.hxx
Dosyayı görüntüle @
017f2507
...
@@ -173,7 +173,7 @@ class StatusIndicatorFactory : public ::cppu::WeakImplHelper4<
...
@@ -173,7 +173,7 @@ class StatusIndicatorFactory : public ::cppu::WeakImplHelper4<
/** Notify us if a fix time is over. We use it to implement an
/** Notify us if a fix time is over. We use it to implement an
intelligent "Reschedule" ... */
intelligent "Reschedule" ... */
WakeUpThread
*
m_pWakeUp
;
rtl
::
Reference
<
WakeUpThread
>
m_pWakeUp
;
/** Our WakeUpThread calls us in our interface method "XUpdatable::update().
/** Our WakeUpThread calls us in our interface method "XUpdatable::update().
There we set this member m_bAllowReschedule to sal_True. Next time if our impl_reschedule()
There we set this member m_bAllowReschedule to sal_True. Next time if our impl_reschedule()
...
...
framework/inc/helper/wakeupthread.hxx
Dosyayı görüntüle @
017f2507
...
@@ -20,57 +20,38 @@
...
@@ -20,57 +20,38 @@
#ifndef INCLUDED_FRAMEWORK_INC_HELPER_WAKEUPTHREAD_HXX
#ifndef INCLUDED_FRAMEWORK_INC_HELPER_WAKEUPTHREAD_HXX
#define INCLUDED_FRAMEWORK_INC_HELPER_WAKEUPTHREAD_HXX
#define INCLUDED_FRAMEWORK_INC_HELPER_WAKEUPTHREAD_HXX
// include files of own module
#include <sal/config.h>
#include <macros/generic.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <general.h>
// include UNO interfaces
#include <com/sun/star/util/XUpdatable.hpp>
// include all others
#include <cppuhelper/weakref.hxx>
#include <cppuhelper/weakref.hxx>
#include <osl/thread.hxx>
#include <osl/conditn.hxx>
#include <osl/mutex.hxx>
#include <sal/types.h>
#include <salhelper/thread.hxx>
namespace
framework
{
namespace
com
{
namespace
sun
{
namespace
star
{
namespace
util
{
class
XUpdatable
;
/** @short implements a "sleeping" thread, which try to sleep
}
}
}
}
without a using cpu consumption :-) */
class
WakeUpThread
:
public
::
osl
::
Thread
{
// member
namespace
framework
{
private
:
/** @short this listener will be notified if this thread
waked up. */
css
::
uno
::
WeakReference
<
css
::
util
::
XUpdatable
>
m_xListener
;
// interface
class
WakeUpThread
:
public
salhelper
::
Thread
{
public
:
css
::
uno
::
WeakReference
<
css
::
util
::
XUpdatable
>
updatable_
;
osl
::
Condition
condition_
;
/** @short Register a new listener on this thread.
osl
::
Mutex
mutex_
;
bool
terminate_
;
@descr The listener is holded as a weak reference.
void
execute
()
SAL_OVERRIDE
;
If the thread detects, that no listener exists ...
he will terminate itself.
*/
WakeUpThread
(
const
css
::
uno
::
Reference
<
css
::
util
::
XUpdatable
>&
xListener
);
/** @descr The thread waits on a condition using a fix timeout value.
public
:
If the thread wakes up he notify the internal set listener.
WakeUpThread
(
css
::
uno
::
Reference
<
css
::
util
::
XUpdatable
>
const
&
updatable
);
The listener can use this "timeout" info for it's own purpose.
The thread itself will wait on the condition again.
*/
virtual
void
SAL_CALL
run
()
SAL_OVERRIDE
;
virtual
void
SAL_CALL
onTerminated
()
SAL_OVERRIDE
;
void
stop
()
;
};
};
}
// namespace framework
}
#endif
// INCLUDED_FRAMEWORK_INC_HELPER_WAKEUPTHREAD_HXX
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
framework/source/helper/statusindicatorfactory.cxx
Dosyayı görüntüle @
017f2507
...
@@ -55,7 +55,6 @@ const char PROGRESS_RESOURCE[] = "private:resource/progressbar/progressbar";
...
@@ -55,7 +55,6 @@ const char PROGRESS_RESOURCE[] = "private:resource/progressbar/progressbar";
StatusIndicatorFactory
::
StatusIndicatorFactory
(
const
css
::
uno
::
Reference
<
css
::
uno
::
XComponentContext
>&
xContext
)
StatusIndicatorFactory
::
StatusIndicatorFactory
(
const
css
::
uno
::
Reference
<
css
::
uno
::
XComponentContext
>&
xContext
)
:
m_xContext
(
xContext
)
:
m_xContext
(
xContext
)
,
m_pWakeUp
(
0
)
,
m_bAllowReschedule
(
false
)
,
m_bAllowReschedule
(
false
)
,
m_bAllowParentShow
(
false
)
,
m_bAllowParentShow
(
false
)
,
m_bDisableReschedule
(
false
)
,
m_bDisableReschedule
(
false
)
...
@@ -542,21 +541,18 @@ void StatusIndicatorFactory::impl_startWakeUpThread()
...
@@ -542,21 +541,18 @@ void StatusIndicatorFactory::impl_startWakeUpThread()
if
(
m_bDisableReschedule
)
if
(
m_bDisableReschedule
)
return
;
return
;
if
(
!
m_pWakeUp
)
if
(
!
m_pWakeUp
.
is
()
)
{
{
m_pWakeUp
=
new
WakeUpThread
(
this
);
m_pWakeUp
=
new
WakeUpThread
(
this
);
m_pWakeUp
->
create
();
}
}
}
}
void
StatusIndicatorFactory
::
impl_stopWakeUpThread
()
void
StatusIndicatorFactory
::
impl_stopWakeUpThread
()
{
{
osl
::
MutexGuard
g
(
m_mutex
);
osl
::
MutexGuard
g
(
m_mutex
);
if
(
m_pWakeUp
)
if
(
m_pWakeUp
.
is
()
)
{
{
// Thread kill itself after terminate()!
m_pWakeUp
->
stop
();
m_pWakeUp
->
terminate
();
m_pWakeUp
=
0
;
}
}
}
}
...
...
framework/source/helper/wakeupthread.cxx
Dosyayı görüntüle @
017f2507
...
@@ -19,44 +19,41 @@
...
@@ -19,44 +19,41 @@
#include <sal/config.h>
#include <sal/config.h>
#include <osl/conditn.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/util/XUpdatable.hpp>
#include <osl/mutex.hxx>
#include <osl/time.h>
// include files of own module
#include <helper/wakeupthread.hxx>
#include <helper/wakeupthread.hxx>
namespace
framework
{
void
framework
::
WakeUpThread
::
execute
()
{
for
(;;)
{
WakeUpThread
::
WakeUpThread
(
const
css
::
uno
::
Reference
<
css
::
util
::
XUpdatable
>&
xListener
)
TimeValue
t
{
0
,
25000000
};
// 25 msec
:
m_xListener
(
xListener
)
condition_
.
wait
(
&
t
);
{
{
osl
::
MutexGuard
g
(
mutex_
);
if
(
terminate_
)
{
break
;
}
}
css
::
uno
::
Reference
<
css
::
util
::
XUpdatable
>
up
(
updatable_
);
if
(
up
.
is
())
{
up
->
update
();
}
}
}
}
void
SAL_CALL
WakeUpThread
::
run
()
framework
::
WakeUpThread
::
WakeUpThread
(
{
css
::
uno
::
Reference
<
css
::
util
::
XUpdatable
>
const
&
updatable
)
:
osl_setThreadName
(
"framework::WakeUpThread"
);
Thread
(
"WakeUpThread"
),
updatable_
(
updatable
),
terminate_
(
false
)
{}
::
osl
::
Condition
aSleeper
;
TimeValue
aTime
;
aTime
.
Seconds
=
0
;
aTime
.
Nanosec
=
25000000
;
// 25 msec
while
(
schedule
())
void
framework
::
WakeUpThread
::
stop
()
{
{
{
aSleeper
.
reset
();
osl
::
MutexGuard
g
(
mutex_
);
aSleeper
.
wait
(
&
aTime
);
terminate_
=
true
;
css
::
uno
::
Reference
<
css
::
util
::
XUpdatable
>
xListener
(
m_xListener
);
if
(
xListener
.
is
())
xListener
->
update
();
}
}
join
();
}
}
void
SAL_CALL
WakeUpThread
::
onTerminated
()
{
delete
this
;
}
}
// namespace framework
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment