]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | /* | |
4 | * Ceph - scalable distributed file system | |
5 | * | |
6 | * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net> | |
7 | * | |
8 | * This is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License version 2.1, as published by the Free Software | |
11 | * Foundation. See file COPYING. | |
12 | * | |
13 | */ | |
14 | ||
15 | #ifndef OP_QUEUE_H | |
16 | #define OP_QUEUE_H | |
17 | ||
18 | #include "include/msgr.h" | |
19 | ||
20 | #include <list> | |
21 | #include <functional> | |
22 | ||
23 | namespace ceph { | |
24 | class Formatter; | |
25 | } | |
26 | ||
27 | /** | |
28 | * Abstract class for all Op Queues | |
29 | * | |
30 | * In order to provide optimized code, be sure to declare all | |
11fdf7f2 | 31 | * virtual functions as final in the derived class. |
7c673cae FG |
32 | */ |
33 | ||
34 | template <typename T, typename K> | |
35 | class OpQueue { | |
9f95a23c TL |
36 | public: |
37 | // Ops of this class should be deleted immediately. If out isn't | |
38 | // nullptr then items should be added to the front in | |
39 | // front-to-back order. The typical strategy is to visit items in | |
40 | // the queue in *reverse* order and to use *push_front* to insert | |
41 | // them into out. | |
42 | virtual void remove_by_class(K k, std::list<T> *out) = 0; | |
7c673cae | 43 | |
9f95a23c TL |
44 | // Enqueue op in the back of the strict queue |
45 | virtual void enqueue_strict(K cl, unsigned priority, T &&item) = 0; | |
46 | ||
47 | // Enqueue op in the front of the strict queue | |
48 | virtual void enqueue_strict_front(K cl, unsigned priority, T &&item) = 0; | |
49 | ||
50 | // Enqueue op in the back of the regular queue | |
51 | virtual void enqueue(K cl, unsigned priority, unsigned cost, T &&item) = 0; | |
52 | ||
53 | // Enqueue the op in the front of the regular queue | |
54 | virtual void enqueue_front( | |
55 | K cl, unsigned priority, unsigned cost, T &&item) = 0; | |
56 | ||
57 | // Returns if the queue is empty | |
58 | virtual bool empty() const = 0; | |
59 | ||
60 | // Return an op to be dispatch | |
61 | virtual T dequeue() = 0; | |
62 | ||
63 | // Formatted output of the queue | |
64 | virtual void dump(ceph::Formatter *f) const = 0; | |
65 | ||
66 | // Human readable brief description of queue and relevant parameters | |
67 | virtual void print(std::ostream &f) const = 0; | |
68 | ||
69 | // Don't leak resources on destruction | |
70 | virtual ~OpQueue() {}; | |
7c673cae FG |
71 | }; |
72 | ||
73 | #endif |