1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
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.
18 #include "include/msgr.h"
28 * Abstract class for all Op Queues
30 * In order to provide optimized code, be sure to declare all
31 * virutal functions as final in the derived class.
34 template <typename T, typename K>
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
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() {};