Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / common / OpQueue.h
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
31  * virutal functions as final in the derived class.
32  */
33
34 template <typename T, typename K>
35 class OpQueue {
36
37   public:
38     // How many Ops are in the queue
39     virtual unsigned length() const = 0;
40     // Ops of this class should be deleted immediately. If out isn't
41     // nullptr then items should be added to the front in
42     // front-to-back order. The typical strategy is to visit items in
43     // the queue in *reverse* order and to use *push_front* to insert
44     // them into out.
45     virtual void remove_by_class(K k, std::list<T> *out) = 0;
46     // Enqueue op in the back of the strict queue
47     virtual void enqueue_strict(K cl, unsigned priority, T item) = 0;
48     // Enqueue op in the front of the strict queue
49     virtual void enqueue_strict_front(K cl, unsigned priority, T item) = 0;
50     // Enqueue op in the back of the regular queue
51     virtual void enqueue(K cl, unsigned priority, unsigned cost, T item) = 0;
52     // Enqueue the op in the front of the regular queue
53     virtual void enqueue_front(K cl, unsigned priority, unsigned cost, T item) = 0;
54     // Returns if the queue is empty
55     virtual bool empty() const = 0;
56     // Return an op to be dispatch
57     virtual T dequeue() = 0;
58     // Formatted output of the queue
59     virtual void dump(ceph::Formatter *f) const = 0;
60     // Don't leak resources on destruction
61     virtual ~OpQueue() {}; 
62 };
63
64 #endif