comparison Plugin/Cache/CacheScheduler.h @ 0:02f7a0400a91

initial commit
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 25 Feb 2015 13:45:35 +0100
parents
children ecefd45026bf
comparison
equal deleted inserted replaced
-1:000000000000 0:02f7a0400a91
1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 *
6 * This program is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU Affero General Public License
8 * as published by the Free Software Foundation, either version 3 of
9 * the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 **/
19
20
21 #pragma once
22
23 #include "CacheManager.h"
24 #include "ICacheFactory.h"
25 #include "IPrefetchPolicy.h"
26 #include "../../Orthanc/MultiThreading/SharedMessageQueue.h"
27
28 #include <boost/thread.hpp>
29 #include <stdio.h>
30
31 namespace OrthancPlugins
32 {
33 class CacheScheduler : public boost::noncopyable
34 {
35 private:
36 class Prefetcher;
37 class PrefetchQueue;
38 class BundleScheduler;
39
40 typedef std::map<int, BundleScheduler*> BundleSchedulers;
41
42 size_t maxPrefetchSize_;
43
44 boost::mutex cacheMutex_;
45 boost::mutex factoryMutex_;
46 boost::recursive_mutex policyMutex_;
47 CacheManager& cache_;
48 std::auto_ptr<IPrefetchPolicy> policy_;
49 BundleSchedulers bundles_;
50
51 void ApplyPrefetchPolicy(int bundle,
52 const std::string& item,
53 const std::string& content);
54
55 BundleScheduler& GetBundleScheduler(unsigned int bundleIndex);
56
57 public:
58 CacheScheduler(CacheManager& cache,
59 unsigned int maxPrefetchSize);
60
61 ~CacheScheduler();
62
63 void Register(int bundle,
64 ICacheFactory* factory /* takes ownership */,
65 size_t numThreads);
66
67 void RegisterPolicy(IPrefetchPolicy* policy /* takes ownership */);
68
69 void Invalidate(int bundle,
70 const std::string& item);
71
72 bool Access(std::string& content,
73 int bundle,
74 const std::string& item);
75
76 void Prefetch(int bundle,
77 const std::string& item);
78 };
79 }