1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SD_SOURCE_UI_SLIDESORTER_CACHE_SLSQUEUEPROCESSOR_HXX
21 #define INCLUDED_SD_SOURCE_UI_SLIDESORTER_CACHE_SLSQUEUEPROCESSOR_HXX
23 #include <cache/SlsCacheContext.hxx>
24 #include "SlsRequestPriorityClass.hxx"
25 #include "SlsBitmapFactory.hxx"
27 #include <vcl/timer.hxx>
29 namespace sd::slidesorter::cache
{
34 /** This queue processor is timer based, i.e. when an entry is added to the
35 queue and the processor is started with Start() in the base class a
36 timer is started that eventually calls ProcessRequest(). This is
37 repeated until the queue is empty or Stop() is called.
39 class QueueProcessor final
44 const std::shared_ptr
<BitmapCache
>& rpCache
,
45 const Size
& rPreviewSize
,
46 const bool bDoSuperSampling
,
47 const SharedCacheContext
& rpCacheContext
);
50 /** Start the processor. This implementation is timer based and waits
51 a defined amount of time that depends on the given argument before
52 the next entry in the queue is processed.
54 A priority class of 0 tells the processor that a high priority
55 request is waiting in the queue. The time to wait is thus
56 shorter then that for a low priority request (denoted by a value
57 of 1.) When the timer is already running it is not modified.
59 void Start (int nPriorityClass
);
66 const bool bDoSuperSampling
);
68 /** Use this method when the page cache is (maybe) using a different
69 BitmapCache. This is usually necessary after calling
70 PageCacheManager::ChangeSize().
72 void SetBitmapCache (const std::shared_ptr
<BitmapCache
>& rpCache
);
75 /** This mutex is used to guard the queue processor. Be careful not to
76 mix its use with that of the solar mutex.
81 DECL_LINK(ProcessRequestHdl
, Timer
*, void);
83 bool mbDoSuperSampling
;
84 SharedCacheContext mpCacheContext
;
85 RequestQueue
& mrQueue
;
86 std::shared_ptr
<BitmapCache
> mpCache
;
87 BitmapFactory maBitmapFactory
;
90 void ProcessRequests();
91 void ProcessOneRequest (
93 const RequestPriorityClass ePriorityClass
);
96 } // end of namespace ::sd::slidesorter::cache
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */