1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cachewritescheduler.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef CONFIGMGR_CACHEWRITESCHEDULER_HXX
32 #define CONFIGMGR_CACHEWRITESCHEDULER_HXX
34 #include "datalock.hxx"
35 #include "requestoptions.hxx"
36 #include "timestamp.hxx"
37 #include "utility.hxx"
43 #include <vos/timer.hxx>
45 #include <vos/ref.hxx>
48 #include <osl/mutex.hxx>
50 // -----------------------------------------------------------------------------
54 namespace backend
{ class ComponentRequest
; class CacheController
; }
56 // Write down the Cache, much less complex than caching Nodes
58 class OCacheWriteScheduler
60 typedef std::set
< RequestOptions
, lessRequestOptions
> CacheWriteList
; // fire and forget!
62 class Timer
: public vos::OTimer
65 OCacheWriteScheduler
* pParent
;
67 Timer(OCacheWriteScheduler
& _rParent
) : pParent(&_rParent
) {};
70 virtual void SAL_CALL
onShot();
72 // stop the scheduling
79 friend void Timer::onShot();
81 vos::ORef
<Timer
> m_xTimer
;
82 backend::CacheController
&m_rTreeManager
;
83 CacheWriteList m_aWriteList
;
84 TimeInterval m_aWriteInterval
;
87 //-------- Construction and destruction -----------------------------------
89 OCacheWriteScheduler(backend::CacheController
& _rTreeManager
, TimeInterval
const& _aWriteInterval
)
90 : m_rTreeManager(_rTreeManager
)
91 , m_aWriteInterval(_aWriteInterval
)
93 m_xTimer
= new Timer(*this);
95 ~OCacheWriteScheduler();
97 //-------- Delay and Interval ---------------------------------------------
98 /// retrieves the recurrance interval used for cleanup
99 TimeInterval
const& getWriteInterval() const
102 return m_aWriteInterval
;
105 static TimeStamp
implGetScheduleTime(TimeStamp
const& aBaseTime
, TimeInterval
const& aDelay
)
107 return aBaseTime
+ aDelay
;
109 //-------- Control of execution ------------------------------------------
110 void scheduleWrite(backend::ComponentRequest _aComponent
) SAL_THROW((com::sun::star::uno::Exception
));
112 /// stop pending activities for one set of options (do not discard them)
113 bool clearTasks(RequestOptions
const& _xOptions
);
115 /// stop and discard pending activities
116 void stopAndWriteCache();
122 void implStartBefore(TimeStamp
const& _aTime
);
123 void writeOneTreeFoundByOption(RequestOptions
const& _aOption
) SAL_THROW((com::sun::star::uno::Exception
));
125 } // namespace configmgr
127 #endif // CONFIGMGR_DISPOSETIMER_HXX