Kaydet (Commit) 09c5a9d4 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Revert "std::list for Scheduler"

This reverts commit 1289d3c4, plus follow-ups
762e90ff "vcl: loplugin:pointertobool" and
863e5685 "Fix funny line-ends," as it causes
memory corruption, see valgrind "make CppunitTest_sw_ooxmlexport4" output:

> Invalid write of size 1
>  Scheduler::ImplInvoke(unsigned long) (/vcl/source/app/scheduler.cxx:40)
>  Scheduler::ProcessTaskScheduling(bool) (/vcl/source/app/scheduler.cxx:128)
>  Scheduler::CallbackTaskScheduling(bool) (/vcl/source/app/scheduler.cxx:112)
>  SalTimer::CallCallback(bool) (/vcl/inc/saltimer.hxx:53)
>  SvpSalInstance::CheckTimeout(bool) (/vcl/headless/svpinst.cxx:191)
>  SvpSalInstance::Yield(bool, bool) (/vcl/headless/svpinst.cxx:307)
>  ImplYield(bool, bool) (/vcl/source/app/svapp.cxx:353)
>  Application::Reschedule(bool) (/vcl/source/app/svapp.cxx:377)
>  framework::StatusIndicatorFactory::impl_reschedule(bool) (/framework/source/helper/statusindicatorfactory.cxx:528)
>  framework::StatusIndicatorFactory::end(com::sun::star::uno::Reference<com::sun::star::task::XStatusIndicator> const&) (/framework/source/helper/statusindicatorfactory.cxx:229)
>  framework::StatusIndicator::end() (/framework/source/helper/statusindicator.cxx:70)
>  non-virtual thunk to framework::StatusIndicator::end() (/framework/source/helper/statusindicator.cxx:57)
>  writerfilter::ooxml::OOXMLDocumentImpl::resolve(writerfilter::Stream&) (/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx:531)
>  WriterFilter::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/writerfilter/source/filter/WriterFilter.cxx:191)
>  non-virtual thunk to WriterFilter::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/writerfilter/source/filter/WriterFilter.cxx:126)
>  SfxObjectShell::ImportFrom(SfxMedium&, com::sun::star::uno::Reference<com::sun::star::text::XTextRange> const&) (/sfx2/source/doc/objstor.cxx:2271)
>  SfxObjectShell::DoLoad(SfxMedium*) (/sfx2/source/doc/objstor.cxx:767)
>  SfxBaseModel::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/sfx2/source/doc/sfxbasemodel.cxx:1859)
>  non-virtual thunk to SfxBaseModel::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/sfx2/source/doc/sfxbasemodel.cxx:1810)
>  (anonymous namespace)::SfxFrameLoader_Impl::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&) (/sfx2/source/view/frmload.cxx:703)
>  non-virtual thunk to (anonymous namespace)::SfxFrameLoader_Impl::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&) (/sfx2/source/view/frmload.cxx:615)
>  framework::LoadEnv::impl_loadContent() (/framework/source/loadenv/loadenv.cxx:1122)
>  framework::LoadEnv::startLoading() (/framework/source/loadenv/loadenv.cxx:383)
>  framework::LoadEnv::loadComponentFromURL(com::sun::star::uno::Reference<com::sun::star::frame::XComponentLoader> const&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/framework/source/loadenv/loadenv.cxx:164)
>  framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/framework/source/services/desktop.cxx:566)
>  non-virtual thunk to framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/framework/source/services/desktop.cxx:552)
>  unotest::MacrosTest::loadFromDesktop(rtl::OUString const&, rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/unotest/source/cpp/macros_test.cxx:50)
>  SwModelTestBase::load(char const*, char const*) (/sw/qa/extras/inc/swmodeltestbase.hxx:580)
>  SwModelTestBase::executeImportExportImportTest(char const*) (/sw/qa/extras/inc/swmodeltestbase.hxx:219)
>  testTrackChangesDeletedParagraphMark::Import_Export_Import() (/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx:132)
>  CppUnit::TestCaller<testTrackChangesDeletedParagraphMark>::runTest() (/workdir/UnpackedTarball/cppunit/include/cppunit/TestCaller.h:166)
>  CppUnit::TestCaseMethodFunctor::operator()() const (/workdir/UnpackedTarball/cppunit/src/cppunit/TestCase.cpp:32)
>  (anonymous namespace)::Protector::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/test/source/vclbootstrapprotector.cxx:57)
>  CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2)
>  (anonymous namespace)::Prot::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (in /home/sbergman/lo/core/workdir/LinkTarget/Library/unobootstrapprotector.so)
>  CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2)
>  (anonymous namespace)::Prot::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx:63)
>  CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2)
>  CppUnit::DefaultProtector::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/workdir/UnpackedTarball/cppunit/src/cppunit/DefaultProtector.cpp:15)
>  CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2)
>  CppUnit::ProtectorChain::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/workdir/UnpackedTarball/cppunit/src/cppunit/ProtectorChain.cpp:77)
>  CppUnit::TestResult::protect(CppUnit::Functor const&, CppUnit::Test*, std::string const&) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestResult.cpp:181)
>  CppUnit::TestCase::run(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestCase.cpp:91)
>  CppUnit::TestComposite::doRunChildTests(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:64)
>  CppUnit::TestComposite::run(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:23)
>  CppUnit::TestComposite::doRunChildTests(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:64)
>  CppUnit::TestComposite::run(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:23)
>  CppUnit::TestRunner::WrappingSuite::run(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestRunner.cpp:47)
>  CppUnit::TestResult::runTest(CppUnit::Test*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestResult.cpp:148)
>  CppUnit::TestRunner::run(CppUnit::TestResult&, std::string const&) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestRunner.cpp:96)
> Address 0x2c9ece48 is 40 bytes inside a block of size 104 free'd
>  operator delete(void*) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
>  (anonymous namespace)::ImpTimedRefDev::~ImpTimedRefDev() (/drawinglayer/source/primitive2d/textlayoutdevice.cxx:84)
>  std::default_delete<(anonymous namespace)::ImpTimedRefDev>::operator()((anonymous namespace)::ImpTimedRefDev*) const (/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/bits/unique_ptr.h:76)
>  std::unique_ptr<(anonymous namespace)::ImpTimedRefDev, std::default_delete<(anonymous namespace)::ImpTimedRefDev> >::reset((anonymous namespace)::ImpTimedRefDev*) (/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/bits/unique_ptr.h:344)
>  comphelper::unique_disposing_ptr<(anonymous namespace)::ImpTimedRefDev>::reset((anonymous namespace)::ImpTimedRefDev*) (/include/comphelper/unique_disposing_ptr.hxx:41)
>  (anonymous namespace)::ImpTimedRefDev::Invoke() (/drawinglayer/source/primitive2d/textlayoutdevice.cxx:93)
>  Scheduler::ImplInvoke(unsigned long) (/vcl/source/app/scheduler.cxx:39)
>  Scheduler::ProcessTaskScheduling(bool) (/vcl/source/app/scheduler.cxx:128)
>  Scheduler::CallbackTaskScheduling(bool) (/vcl/source/app/scheduler.cxx:112)
>  SalTimer::CallCallback(bool) (/vcl/inc/saltimer.hxx:53)
>  SvpSalInstance::CheckTimeout(bool) (/vcl/headless/svpinst.cxx:191)
>  SvpSalInstance::Yield(bool, bool) (/vcl/headless/svpinst.cxx:307)
>  ImplYield(bool, bool) (/vcl/source/app/svapp.cxx:353)
>  Application::Reschedule(bool) (/vcl/source/app/svapp.cxx:377)
>  framework::StatusIndicatorFactory::impl_reschedule(bool) (/framework/source/helper/statusindicatorfactory.cxx:528)
>  framework::StatusIndicatorFactory::end(com::sun::star::uno::Reference<com::sun::star::task::XStatusIndicator> const&) (/framework/source/helper/statusindicatorfactory.cxx:229)
>  framework::StatusIndicator::end() (/framework/source/helper/statusindicator.cxx:70)
>  non-virtual thunk to framework::StatusIndicator::end() (/framework/source/helper/statusindicator.cxx:57)
>  writerfilter::ooxml::OOXMLDocumentImpl::resolve(writerfilter::Stream&) (/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx:531)
>  WriterFilter::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/writerfilter/source/filter/WriterFilter.cxx:191)
>  non-virtual thunk to WriterFilter::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/writerfilter/source/filter/WriterFilter.cxx:126)
>  SfxObjectShell::ImportFrom(SfxMedium&, com::sun::star::uno::Reference<com::sun::star::text::XTextRange> const&) (/sfx2/source/doc/objstor.cxx:2271)
>  SfxObjectShell::DoLoad(SfxMedium*) (/sfx2/source/doc/objstor.cxx:767)
>  SfxBaseModel::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/sfx2/source/doc/sfxbasemodel.cxx:1859)
>  non-virtual thunk to SfxBaseModel::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/sfx2/source/doc/sfxbasemodel.cxx:1810)
>  (anonymous namespace)::SfxFrameLoader_Impl::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&) (/sfx2/source/view/frmload.cxx:703)
>  non-virtual thunk to (anonymous namespace)::SfxFrameLoader_Impl::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&) (/sfx2/source/view/frmload.cxx:615)
>  framework::LoadEnv::impl_loadContent() (/framework/source/loadenv/loadenv.cxx:1122)
>  framework::LoadEnv::startLoading() (/framework/source/loadenv/loadenv.cxx:383)
>  framework::LoadEnv::loadComponentFromURL(com::sun::star::uno::Reference<com::sun::star::frame::XComponentLoader> const&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/framework/source/loadenv/loadenv.cxx:164)
>  framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/framework/source/services/desktop.cxx:566)
>  non-virtual thunk to framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/framework/source/services/desktop.cxx:552)
>  unotest::MacrosTest::loadFromDesktop(rtl::OUString const&, rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/unotest/source/cpp/macros_test.cxx:50)
>  SwModelTestBase::load(char const*, char const*) (/sw/qa/extras/inc/swmodeltestbase.hxx:580)
>  SwModelTestBase::executeImportExportImportTest(char const*) (/sw/qa/extras/inc/swmodeltestbase.hxx:219)
>  testTrackChangesDeletedParagraphMark::Import_Export_Import() (/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx:132)
>  CppUnit::TestCaller<testTrackChangesDeletedParagraphMark>::runTest() (/workdir/UnpackedTarball/cppunit/include/cppunit/TestCaller.h:166)
>  CppUnit::TestCaseMethodFunctor::operator()() const (/workdir/UnpackedTarball/cppunit/src/cppunit/TestCase.cpp:32)
>  (anonymous namespace)::Protector::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/test/source/vclbootstrapprotector.cxx:57)
>  CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2)
>  (anonymous namespace)::Prot::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (in /home/sbergman/lo/core/workdir/LinkTarget/Library/unobootstrapprotector.so)
>  CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2)
>  (anonymous namespace)::Prot::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx:63)
>  CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2)
>  CppUnit::DefaultProtector::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/workdir/UnpackedTarball/cppunit/src/cppunit/DefaultProtector.cpp:15)
>  CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2)
>  CppUnit::ProtectorChain::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/workdir/UnpackedTarball/cppunit/src/cppunit/ProtectorChain.cpp:77)
>  CppUnit::TestResult::protect(CppUnit::Functor const&, CppUnit::Test*, std::string const&) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestResult.cpp:181)
>  CppUnit::TestCase::run(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestCase.cpp:91)
>  CppUnit::TestComposite::doRunChildTests(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:64)
üst 14aa5c58
...@@ -28,7 +28,6 @@ class VCL_DLLPUBLIC Idle : public Scheduler ...@@ -28,7 +28,6 @@ class VCL_DLLPUBLIC Idle : public Scheduler
protected: protected:
Link<Idle *, void> maIdleHdl; // Callback Link Link<Idle *, void> maIdleHdl; // Callback Link
public: public:
Idle( const sal_Char *pDebugName = NULL ); Idle( const sal_Char *pDebugName = NULL );
Idle( const Idle& rIdle ); Idle( const Idle& rIdle );
......
...@@ -21,17 +21,22 @@ ...@@ -21,17 +21,22 @@
#define INCLUDED_VCL_SCHEDULER_HXX #define INCLUDED_VCL_SCHEDULER_HXX
#include <vcl/dllapi.h> #include <vcl/dllapi.h>
#include <list>
struct ImplSVData;
class Scheduler; class Scheduler;
struct ImplSchedulerData struct ImplSchedulerData
{ {
bool mbDelete; // Destroy this scheduler? ImplSchedulerData* mpNext; // Pointer to the next element in list
Scheduler* mpScheduler; // Pointer to VCL Scheduler instance Scheduler* mpScheduler; // Pointer to VCL Scheduler instance
}; bool mbDelete; // Destroy this scheduler?
bool mbInScheduler; // Scheduler currently processed?
sal_uInt64 mnUpdateTime; // Last Update Time
sal_uInt32 mnUpdateStack; // Update Stack
#define MAX_TIMER_PERIOD SAL_MAX_UINT64 void Invoke();
static ImplSchedulerData *GetMostImportantTask( bool bTimer );
};
enum class SchedulerPriority { enum class SchedulerPriority {
HIGHEST = 0, HIGHEST = 0,
...@@ -51,7 +56,6 @@ protected: ...@@ -51,7 +56,6 @@ protected:
const sal_Char *mpDebugName; /// Useful for debugging const sal_Char *mpDebugName; /// Useful for debugging
SchedulerPriority mePriority; /// Scheduler priority SchedulerPriority mePriority; /// Scheduler priority
bool mbActive; /// Currently in the scheduler bool mbActive; /// Currently in the scheduler
sal_uInt64 mnUpdateTime; /// Last Update Time
friend struct ImplSchedulerData; friend struct ImplSchedulerData;
virtual void SetDeletionFlags(); virtual void SetDeletionFlags();
...@@ -79,27 +83,14 @@ public: ...@@ -79,27 +83,14 @@ public:
void SetInActive() { mbActive = false; } void SetInActive() { mbActive = false; }
Scheduler& operator=( const Scheduler& rScheduler ); Scheduler& operator=( const Scheduler& rScheduler );
static void ImplDeInitScheduler(bool bAll=true); static void ImplDeInitScheduler();
static void ImplInitScheduler();
// Process one pending Timer with highest priority // Process one pending Timer with highhest priority
static void CallbackTaskScheduling( bool ignore ); static void CallbackTaskScheduling( bool ignore );
/// Process one pending task ahead of time with highest priority. /// Process one pending task ahead of time with highhest priority.
static void ProcessTaskScheduling( bool bTimer ); static void ProcessTaskScheduling( bool bTimer );
private:
bool mbInScheduler; // Scheduler currently processed?
sal_uInt32 mnUpdateStack; // Update Stack
bool ImplHandleTaskScheduling(sal_uInt64& nMinPeriod, sal_uInt64 nTime);
void ImplInvoke(sal_uInt64 nTime);
static Scheduler* ImplGetHighestPrioTask( bool bTimer );
bool ImplIsScheduleReady(sal_uInt32 nUpdateStack);
void ImplDispose();
}; };
typedef ::std::list< ImplSchedulerData* > ImplScheduler_t;
#endif // INCLUDED_VCL_SCHEDULER_HXX #endif // INCLUDED_VCL_SCHEDULER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
#include <tools/link.hxx> #include <tools/link.hxx>
#include <vcl/scheduler.hxx> #include <vcl/scheduler.hxx>
struct ImplSVData;
class VCL_DLLPUBLIC Timer : public Scheduler class VCL_DLLPUBLIC Timer : public Scheduler
{ {
protected: protected:
......
...@@ -109,7 +109,7 @@ void SAL_CALL SfxTerminateListener_Impl::notifyTermination( const EventObject& a ...@@ -109,7 +109,7 @@ void SAL_CALL SfxTerminateListener_Impl::notifyTermination( const EventObject& a
// Timers may access the SfxApplication and are only deleted in // Timers may access the SfxApplication and are only deleted in
// Application::Quit(), which is asynchronous (PostUserEvent) - disable! // Application::Quit(), which is asynchronous (PostUserEvent) - disable!
Scheduler::ImplDeInitScheduler(false); // false only delete the list Scheduler::ImplDeInitScheduler();
SfxApplication* pApp = SfxGetpApp(); SfxApplication* pApp = SfxGetpApp();
pApp->Broadcast( SfxSimpleHint( SFX_HINT_DEINITIALIZING ) ); pApp->Broadcast( SfxSimpleHint( SFX_HINT_DEINITIALIZING ) );
......
...@@ -313,7 +313,7 @@ struct ImplSVData ...@@ -313,7 +313,7 @@ struct ImplSVData
bool mbDeInit; // Is VCL deinitializing bool mbDeInit; // Is VCL deinitializing
sal_uLong mnThreadCount; // is VCL MultiThread enabled sal_uLong mnThreadCount; // is VCL MultiThread enabled
ImplConfigData* mpFirstConfigData; // pointer to the first config block ImplConfigData* mpFirstConfigData; // pointer to the first config block
ImplScheduler_t* maSchedulers; // list of all running tasks ImplSchedulerData* mpFirstSchedulerData; // list of all running tasks
SalTimer* mpSalTimer; // interface to sal event loop/timers SalTimer* mpSalTimer; // interface to sal event loop/timers
SalI18NImeStatus* mpImeStatus; // interface to ime status window SalI18NImeStatus* mpImeStatus; // interface to ime status window
SalSystem* mpSalSystem; // SalSystem interface SalSystem* mpSalSystem; // SalSystem interface
......
...@@ -75,4 +75,5 @@ sal_uInt64 Idle::UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 /* nTime */ ...@@ -75,4 +75,5 @@ sal_uInt64 Idle::UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 /* nTime */
return nMinPeriod; return nMinPeriod;
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -21,88 +21,85 @@ ...@@ -21,88 +21,85 @@
#include <tools/time.hxx> #include <tools/time.hxx>
#include <vcl/scheduler.hxx> #include <vcl/scheduler.hxx>
#include <vcl/timer.hxx> #include <vcl/timer.hxx>
#include <algorithm>
#include <saltimer.hxx> #include <saltimer.hxx>
void Scheduler::ImplInvoke(sal_uInt64 nTime) #define MAX_TIMER_PERIOD SAL_MAX_UINT64
{
mnUpdateTime = nTime;
if (mpSchedulerData->mbDelete || mbInScheduler ) void ImplSchedulerData::Invoke()
{
if (mbDelete || mbInScheduler )
return; return;
// prepare Scheduler Object for deletion after handling // prepare Scheduler Object for deletion after handling
SetDeletionFlags(); mpScheduler->SetDeletionFlags();
// invoke it // invoke it
mbInScheduler = true; mbInScheduler = true;
Invoke(); mpScheduler->Invoke();
mbInScheduler = false; mbInScheduler = false;
} }
Scheduler* Scheduler::ImplGetHighestPrioTask( bool bTimer ) ImplSchedulerData *ImplSchedulerData::GetMostImportantTask( bool bTimer )
{ {
ImplSVData* pSVData = ImplGetSVData(); ImplSVData* pSVData = ImplGetSVData();
Scheduler * pMostUrgent = NULL; ImplSchedulerData *pMostUrgent = NULL;
std::for_each(pSVData->maSchedulers->begin(), pSVData->maSchedulers->end(), for ( ImplSchedulerData *pSchedulerData = pSVData->mpFirstSchedulerData; pSchedulerData; pSchedulerData = pSchedulerData->mpNext )
[&pSVData, bTimer, &pMostUrgent] (ImplSchedulerData *rScheduler)
{
if ( rScheduler->mpScheduler &&
rScheduler->mpScheduler->ImplIsScheduleReady(pSVData->mnUpdateStack) &&
rScheduler->mpScheduler->ReadyForSchedule( bTimer ) &&
rScheduler->mpScheduler->IsActive() )
{ {
if ( !pSchedulerData->mpScheduler || pSchedulerData->mbDelete || pSchedulerData->mnUpdateStack >= pSVData->mnUpdateStack
|| !pSchedulerData->mpScheduler->ReadyForSchedule( bTimer ) || !pSchedulerData->mpScheduler->IsActive())
continue;
if (!pMostUrgent) if (!pMostUrgent)
pMostUrgent = rScheduler->mpScheduler; pMostUrgent = pSchedulerData;
else else
{ {
// Find the highest priority. // Find the highest priority.
// If the priority of the current task is higher (numerical value is lower) than // If the priority of the current task is higher (numerical value is lower) than
// the priority of the most urgent, the current task gets the new most urgent. // the priority of the most urgent, the current task gets the new most urgent.
if ( rScheduler->mpScheduler->GetPriority() < pMostUrgent->GetPriority() ) if ( pSchedulerData->mpScheduler->GetPriority() < pMostUrgent->mpScheduler->GetPriority() )
pMostUrgent = rScheduler->mpScheduler; pMostUrgent = pSchedulerData;
} }
} }
});
return pMostUrgent; return pMostUrgent;
} }
void Scheduler::SetDeletionFlags() void Scheduler::SetDeletionFlags()
{ {
Stop(); mpSchedulerData->mbDelete = true;
mbActive = false;
} }
void Scheduler::ImplDeInitScheduler(bool bAll /*=true*/) void Scheduler::ImplDeInitScheduler()
{ {
ImplSVData* pSVData = ImplGetSVData(); ImplSVData* pSVData = ImplGetSVData();
ImplSchedulerData* pSchedulerData = pSVData->mpFirstSchedulerData;
if (pSVData->mpSalTimer) if (pSVData->mpSalTimer)
{ {
pSVData->mpSalTimer->Stop(); pSVData->mpSalTimer->Stop();
} }
pSVData->maSchedulers->remove_if( [] (ImplSchedulerData *rSchedulerData) if ( pSchedulerData )
{
do
{ {
if(rSchedulerData->mpScheduler != NULL) ImplSchedulerData* pTempSchedulerData = pSchedulerData;
if ( pSchedulerData->mpScheduler )
{ {
rSchedulerData->mpScheduler->ImplDispose(); pSchedulerData->mpScheduler->mbActive = false;
pSchedulerData->mpScheduler->mpSchedulerData = NULL;
} }
else pSchedulerData = pSchedulerData->mpNext;
delete rSchedulerData; delete pTempSchedulerData;
}
return true; while ( pSchedulerData );
});
if(bAll) pSVData->mpFirstSchedulerData = NULL;
{ pSVData->mnTimerPeriod = 0;
delete pSVData->maSchedulers;
pSVData->maSchedulers = NULL;
} }
delete pSVData->mpSalTimer; delete pSVData->mpSalTimer;
pSVData->mpSalTimer = NULL; pSVData->mpSalTimer = 0;
} }
void Scheduler::CallbackTaskScheduling(bool ignore) void Scheduler::CallbackTaskScheduling(bool ignore)
...@@ -116,30 +113,52 @@ void Scheduler::ProcessTaskScheduling( bool bTimer ) ...@@ -116,30 +113,52 @@ void Scheduler::ProcessTaskScheduling( bool bTimer )
{ {
// process all pending Tasks // process all pending Tasks
// if bTimer True, only handle timer // if bTimer True, only handle timer
Scheduler* pScheduler = NULL; ImplSchedulerData* pSchedulerData = NULL;
ImplSchedulerData* pPrevSchedulerData = NULL;
ImplSVData* pSVData = ImplGetSVData(); ImplSVData* pSVData = ImplGetSVData();
sal_uInt64 nTime = tools::Time::GetSystemTicks(); sal_uInt64 nTime = tools::Time::GetSystemTicks();
sal_uInt64 nMinPeriod = MAX_TIMER_PERIOD; sal_uInt64 nMinPeriod = MAX_TIMER_PERIOD;
pSVData->mnUpdateStack++; pSVData->mnUpdateStack++;
// tdf#91727 - NB. bTimer is ultimately not used // tdf#91727 - NB. bTimer is ultimately not used
if ((pScheduler = Scheduler::ImplGetHighestPrioTask(bTimer)) != NULL) if ((pSchedulerData = ImplSchedulerData::GetMostImportantTask(bTimer)))
pScheduler->ImplInvoke(nTime); {
pSchedulerData->mnUpdateTime = nTime;
pSchedulerData->Invoke();
}
pSVData->maSchedulers->remove_if( [&nMinPeriod, nTime, pSVData] (ImplSchedulerData *rSchedulerData) pSchedulerData = pSVData->mpFirstSchedulerData;
while ( pSchedulerData )
{ {
if (rSchedulerData->mpScheduler != 0) if( pSchedulerData->mbInScheduler )
return rSchedulerData->mpScheduler->ImplHandleTaskScheduling(nMinPeriod, nTime); {
pPrevSchedulerData = pSchedulerData;
pSchedulerData = pSchedulerData->mpNext;
}
// Should Task be released from scheduling?
else if ( pSchedulerData->mbDelete )
{
if ( pPrevSchedulerData )
pPrevSchedulerData->mpNext = pSchedulerData->mpNext;
else
pSVData->mpFirstSchedulerData = pSchedulerData->mpNext;
if ( pSchedulerData->mpScheduler )
pSchedulerData->mpScheduler->mpSchedulerData = NULL;
ImplSchedulerData* pTempSchedulerData = pSchedulerData;
pSchedulerData = pSchedulerData->mpNext;
delete pTempSchedulerData;
}
else else
{ {
delete rSchedulerData; pSchedulerData->mnUpdateStack = 0;
return true; nMinPeriod = pSchedulerData->mpScheduler->UpdateMinPeriod( nMinPeriod, nTime );
pPrevSchedulerData = pSchedulerData;
pSchedulerData = pSchedulerData->mpNext;
}
} }
});
// delete clock if no more timers available // delete clock if no more timers available
if ( pSVData->maSchedulers->empty() ) if ( !pSVData->mpFirstSchedulerData )
{ {
if ( pSVData->mpSalTimer ) if ( pSVData->mpSalTimer )
pSVData->mpSalTimer->Stop(); pSVData->mpSalTimer->Stop();
...@@ -149,7 +168,6 @@ void Scheduler::ProcessTaskScheduling( bool bTimer ) ...@@ -149,7 +168,6 @@ void Scheduler::ProcessTaskScheduling( bool bTimer )
{ {
Timer::ImplStartTimer( pSVData, nMinPeriod ); Timer::ImplStartTimer( pSVData, nMinPeriod );
} }
pSVData->mnUpdateStack--; pSVData->mnUpdateStack--;
} }
...@@ -160,22 +178,34 @@ void Scheduler::SetPriority( SchedulerPriority ePriority ) ...@@ -160,22 +178,34 @@ void Scheduler::SetPriority( SchedulerPriority ePriority )
void Scheduler::Start() void Scheduler::Start()
{ {
ImplSVData* pSVData = ImplGetSVData();
// Mark timer active // Mark timer active
mbActive = true; mbActive = true;
ImplSVData* pSVData = ImplGetSVData();
if ( !mpSchedulerData ) if ( !mpSchedulerData )
{ {
// insert Scheduler
mpSchedulerData = new ImplSchedulerData; mpSchedulerData = new ImplSchedulerData;
mpSchedulerData->mpScheduler = this; mpSchedulerData->mpScheduler = this;
// insert Scheduler mpSchedulerData->mbInScheduler = false;
mbInScheduler = false;
pSVData->maSchedulers->push_back(mpSchedulerData);
}
// insert last due to SFX!
ImplSchedulerData* pPrev = NULL;
ImplSchedulerData* pData = pSVData->mpFirstSchedulerData;
while ( pData )
{
pPrev = pData;
pData = pData->mpNext;
}
mpSchedulerData->mpNext = NULL;
if ( pPrev )
pPrev->mpNext = mpSchedulerData;
else
pSVData->mpFirstSchedulerData = mpSchedulerData;
}
mpSchedulerData->mbDelete = false; mpSchedulerData->mbDelete = false;
mnUpdateTime = tools::Time::GetSystemTicks(); mpSchedulerData->mnUpdateTime = tools::Time::GetSystemTicks();
mnUpdateStack = pSVData->mnUpdateStack; mpSchedulerData->mnUpdateStack = pSVData->mnUpdateStack;
} }
void Scheduler::Stop() void Scheduler::Stop()
...@@ -204,17 +234,15 @@ Scheduler::Scheduler(const sal_Char *pDebugName): ...@@ -204,17 +234,15 @@ Scheduler::Scheduler(const sal_Char *pDebugName):
mpSchedulerData(NULL), mpSchedulerData(NULL),
mpDebugName(pDebugName), mpDebugName(pDebugName),
mePriority(SchedulerPriority::HIGH), mePriority(SchedulerPriority::HIGH),
mbActive(false), mbActive(false)
mnUpdateTime(0)
{ {
} }
Scheduler::Scheduler( const Scheduler& rScheduler ): Scheduler::Scheduler( const Scheduler& rScheduler ):
mpSchedulerData(NULL), mpSchedulerData(NULL),
mpDebugName(rScheduler.mpDebugName), mpDebugName(rScheduler.mpDebugName),
mePriority(SchedulerPriority::HIGH), mePriority(rScheduler.mePriority),
mbActive(false), mbActive(false)
mnUpdateTime(0)
{ {
if ( rScheduler.IsActive() ) if ( rScheduler.IsActive() )
Start(); Start();
...@@ -229,44 +257,3 @@ Scheduler::~Scheduler() ...@@ -229,44 +257,3 @@ Scheduler::~Scheduler()
} }
} }
bool Scheduler::ImplIsScheduleReady(sal_uInt32 nUpdateStack)
{
return !mpSchedulerData->mbDelete && (mnUpdateStack <= nUpdateStack);
}
void Scheduler::ImplDispose()
{
mpSchedulerData->mpScheduler = NULL;
delete mpSchedulerData;
mpSchedulerData = NULL;
}
void Scheduler::ImplInitScheduler()
{
ImplSVData* pSVData = ImplGetSVData();
if(pSVData->maSchedulers == NULL)
pSVData->maSchedulers = new ImplScheduler_t;
}
bool Scheduler::ImplHandleTaskScheduling(sal_uInt64 &nMinPeriod, sal_uInt64 nTime)
{
// process all pending Tasks
if( !mbInScheduler )
{
// Should Task be released from scheduling?
if ( !mpSchedulerData->mbDelete )
{
mnUpdateStack = 0;
nMinPeriod = UpdateMinPeriod( nMinPeriod, nTime );
}
else
{
ImplDispose();
return true;
}
}
return false;
}
...@@ -81,8 +81,7 @@ SalSystem* ImplGetSalSystem() ...@@ -81,8 +81,7 @@ SalSystem* ImplGetSalSystem()
ImplSVData::ImplSVData() ImplSVData::ImplSVData()
{ {
// init global instance data // init global instance data
memset( this, 0, sizeof( ImplSVData )); memset( this, 0, sizeof( ImplSVData ) );
maHelpData.mbAutoHelpId = true; maHelpData.mbAutoHelpId = true;
maNWFData.maMenuBarHighlightTextColor = Color( COL_TRANSPARENT ); maNWFData.maMenuBarHighlightTextColor = Color( COL_TRANSPARENT );
} }
......
...@@ -251,8 +251,6 @@ bool InitVCL() ...@@ -251,8 +251,6 @@ bool InitVCL()
// remember Main-Thread-Id // remember Main-Thread-Id
pSVData->mnMainThreadId = ::osl::Thread::getCurrentIdentifier(); pSVData->mnMainThreadId = ::osl::Thread::getCurrentIdentifier();
Scheduler::ImplInitScheduler();
// Initialize Sal // Initialize Sal
pSVData->mpDefInst = CreateSalInstance(); pSVData->mpDefInst = CreateSalInstance();
if ( !pSVData->mpDefInst ) if ( !pSVData->mpDefInst )
...@@ -373,7 +371,6 @@ void DeInitVCL() ...@@ -373,7 +371,6 @@ void DeInitVCL()
if ( pSVData->maAppData.mpIdleMgr ) if ( pSVData->maAppData.mpIdleMgr )
delete pSVData->maAppData.mpIdleMgr; delete pSVData->maAppData.mpIdleMgr;
Scheduler::ImplDeInitScheduler(); Scheduler::ImplDeInitScheduler();
if ( pSVData->maWinData.mpMsgBoxImgList ) if ( pSVData->maWinData.mpMsgBoxImgList )
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <svdata.hxx> #include <svdata.hxx>
#include <salinst.hxx> #include <salinst.hxx>
#define MAX_TIMER_PERIOD SAL_MAX_UINT64
void Timer::ImplStartTimer( ImplSVData* pSVData, sal_uInt64 nMS ) void Timer::ImplStartTimer( ImplSVData* pSVData, sal_uInt64 nMS )
{ {
...@@ -44,23 +45,23 @@ void Timer::SetDeletionFlags() ...@@ -44,23 +45,23 @@ void Timer::SetDeletionFlags()
// if no AutoTimer than stop // if no AutoTimer than stop
if ( !mbAuto ) if ( !mbAuto )
{ {
Scheduler::SetDeletionFlags(); mpSchedulerData->mbDelete = true;
mbActive = false;
} }
} }
bool Timer::ReadyForSchedule( bool bTimer ) bool Timer::ReadyForSchedule( bool bTimer )
{ {
(void)bTimer; (void)bTimer;
return (mnUpdateTime + mnTimeout) <= tools::Time::GetSystemTicks(); return (mpSchedulerData->mnUpdateTime + mnTimeout) <= tools::Time::GetSystemTicks();
} }
sal_uInt64 Timer::UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTime ) sal_uInt64 Timer::UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTime )
{ {
sal_uInt64 nNewTime = tools::Time::GetSystemTicks(); sal_uInt64 nNewTime = tools::Time::GetSystemTicks();
sal_uInt64 nDeltaTime; sal_uInt64 nDeltaTime;
//determine smallest time slot //determine smallest time slot
if( mnUpdateTime == nTime ) if( mpSchedulerData->mnUpdateTime == nTime )
{ {
nDeltaTime = mnTimeout; nDeltaTime = mnTimeout;
if( nDeltaTime < nMinPeriod ) if( nDeltaTime < nMinPeriod )
...@@ -68,7 +69,7 @@ sal_uInt64 Timer::UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTime ) ...@@ -68,7 +69,7 @@ sal_uInt64 Timer::UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTime )
} }
else else
{ {
nDeltaTime = mnUpdateTime + mnTimeout; nDeltaTime = mpSchedulerData->mnUpdateTime + mnTimeout;
if( nDeltaTime < nNewTime ) if( nDeltaTime < nNewTime )
nMinPeriod = 1; nMinPeriod = 1;
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment