forked from membase/ep-engine
/
item_pager.hh
65 lines (52 loc) · 1.58 KB
/
item_pager.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#ifndef ITEM_PAGER_HH
#define ITEM_PAGER_HH 1
#include "common.hh"
#include "dispatcher.hh"
#include "stats.hh"
// Forward declaration.
class EventuallyPersistentStore;
/**
* Dispatcher job responsible for periodically pushing data out of
* memory.
*/
class ItemPager : public DispatcherCallback {
public:
/**
* Construct an ItemPager.
*
* @param s the store (where we'll visit)
* @param st the stats
*/
ItemPager(EventuallyPersistentStore *s, EPStats &st) :
store(s), stats(st) {}
bool callback(Dispatcher &d, TaskId t);
std::string description() { return std::string("Paging out items."); }
private:
EventuallyPersistentStore *store;
EPStats &stats;
};
/**
* Dispatcher job responsible for purging expired items from
* memory and disk.
*/
class ExpiredItemPager : public DispatcherCallback {
public:
/**
* Construct an ExpiredItemPager.
*
* @param s the store (where we'll visit)
* @param st the stats
* @param stime number of seconds to wait between runs
*/
ExpiredItemPager(EventuallyPersistentStore *s, EPStats &st,
size_t stime) :
store(s), stats(st), sleepTime(static_cast<double>(stime)) {}
bool callback(Dispatcher &d, TaskId t);
std::string description() { return std::string("Paging expired items."); }
private:
EventuallyPersistentStore *store;
EPStats &stats;
double sleepTime;
};
#endif /* ITEM_PAGER_HH */