bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / slidesorter / cache / SlsQueueProcessor.hxx
blob48bf21fe9e2e46766e2741f8e2eaf5d40a949d8d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 { namespace slidesorter { namespace cache {
31 class BitmapCache;
32 class RequestQueue;
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
41 public:
42 QueueProcessor (
43 RequestQueue& rQueue,
44 const std::shared_ptr<BitmapCache>& rpCache,
45 const Size& rPreviewSize,
46 const bool bDoSuperSampling,
47 const SharedCacheContext& rpCacheContext);
48 ~QueueProcessor();
50 /** Start the processor. This implementation is timer based and waits
51 an defined amount of time that depends on the given argument before
52 the next entry in the queue is processed.
53 @param nPriorityClass
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);
60 void Stop();
61 void Pause();
62 void Resume();
64 void SetPreviewSize (
65 const Size& rSize,
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);
74 private:
75 /** This mutex is used to guard the queue processor. Be careful not to
76 mix its use with that of the solar mutex.
78 ::osl::Mutex maMutex;
80 Timer maTimer;
81 DECL_LINK(ProcessRequestHdl, Timer *, void);
82 Size maPreviewSize;
83 bool mbDoSuperSampling;
84 SharedCacheContext mpCacheContext;
85 RequestQueue& mrQueue;
86 std::shared_ptr<BitmapCache> mpCache;
87 BitmapFactory maBitmapFactory;
88 bool mbIsPaused;
90 void ProcessRequests();
91 void ProcessOneRequest (
92 CacheKey aKey,
93 const RequestPriorityClass ePriorityClass);
96 } } } // end of namespace ::sd::slidesorter::cache
98 #endif
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */