-
Notifications
You must be signed in to change notification settings - Fork 29
/
priority.hh
66 lines (56 loc) · 1.73 KB
/
priority.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
66
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#ifndef PRIORITY_HH
#define PRIORITY_HH
#include "common.hh"
#include <string>
/**
* Task priority definition.
*/
class Priority {
public:
static const Priority BgFetcherPriority;
static const Priority TapBgFetcherPriority;
static const Priority VBucketPersistHighPriority;
static const Priority VKeyStatBgFetcherPriority;
static const Priority NotifyVBStateChangePriority;
static const Priority FlusherPriority;
static const Priority ItemPagerPriority;
static const Priority VBucketDeletionPriority;
static const Priority VBucketPersistLowPriority;
static const Priority StatSnapPriority;
static const Priority InvalidItemDbPagerPriority;
bool operator==(const Priority &other) const {
return other.getPriorityValue() == this->priority;
}
bool operator<(const Priority &other) const {
return this->priority > other.getPriorityValue();
}
bool operator>(const Priority &other) const {
return this->priority < other.getPriorityValue();
}
/**
* Return a priority name.
*
* @return a priority name
*/
const std::string &toString() const {
return name;
}
/**
* Return an integer value that represents a priority.
*
* @return a priority value
*/
int getPriorityValue() const {
return priority;
}
// gcc didn't like the idea of having a class with no constructor
// available to anyone.. let's make it protected instead to shut
// gcc up :(
protected:
Priority(const char *nm, int p) : name(nm), priority(p) { }
std::string name;
int priority;
DISALLOW_COPY_AND_ASSIGN(Priority);
};
#endif