]>
git.proxmox.com Git - ceph.git/blob - 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
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 * virtual functions as final in the derived class.
34 template <typename T
, typename K
>
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
42 virtual void remove_by_class(K k
, std::list
<T
> *out
) = 0;
44 // Enqueue op in the back of the strict queue
45 virtual void enqueue_strict(K cl
, unsigned priority
, T
&&item
) = 0;
47 // Enqueue op in the front of the strict queue
48 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;
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;
57 // Returns if the queue is empty
58 virtual bool empty() const = 0;
60 // Return an op to be dispatch
61 virtual T
dequeue() = 0;
63 // Formatted output of the queue
64 virtual void dump(ceph::Formatter
*f
) const = 0;
66 // Human readable brief description of queue and relevant parameters
67 virtual void print(std::ostream
&f
) const = 0;
69 // Don't leak resources on destruction
70 virtual ~OpQueue() {};