High performance C++ framework for concurrent servers
Classes | Public Types | Public Member Functions | List of all members
seastar::fair_queue Class Reference

Detailed Description

Fair queuing class.

This is a fair queue, allowing multiple request producers to queue requests that will then be served proportionally to their classes' shares.

To each request, a weight can also be associated. A request of weight 1 will consume 1 share. Higher weights for a request will consume a proportionally higher amount of shares.

The user of this interface is expected to register multiple priority_class_data objects, which will each have a shares attribute.

Internally, each priority class may keep a separate queue of requests. Requests pertaining to a class can go through even if they are over its share limit, provided that the other classes have empty queues.

When the classes that lag behind start seeing requests, the fair queue will serve them first, until balance is restored. This balancing is expected to happen within a certain time window that obeys an exponential decay.

#include <seastar/core/fair_queue.hh>


struct  config
 Fair Queue configuration structure. More...

Public Types

using class_id = unsigned int
using capacity_t = fair_group::capacity_t
using signed_capacity_t = std::make_signed_t< capacity_t >

Public Member Functions

 fair_queue (fair_group &shared, config cfg)
 fair_queue (fair_queue &&)
sstring label () const noexcept
void register_priority_class (class_id c, uint32_t shares)
void unregister_priority_class (class_id c)
void update_shares_for_class (class_id c, uint32_t new_shares)
fair_queue_ticket resources_currently_waiting () const
fair_queue_ticket resources_currently_executing () const
capacity_t tokens_capacity (double tokens) const noexcept
capacity_t maximum_capacity () const noexcept
void queue (class_id c, fair_queue_entry &ent) noexcept
void plug_class (class_id c) noexcept
void unplug_class (class_id c) noexcept
void notify_request_finished (fair_queue_entry::capacity_t cap) noexcept
void notify_request_cancelled (fair_queue_entry &ent) noexcept
void dispatch_requests (std::function< void(fair_queue_entry &)> cb)
 Try to execute new requests if there is capacity left in the queue.
clock_type::time_point next_pending_aio () const noexcept
std::vector< seastar::metrics::impl::metric_definition_implmetrics (class_id c)

Class Documentation

◆ seastar::fair_queue::config

struct seastar::fair_queue::config
Class Members
sstring label
microseconds tau

Constructor & Destructor Documentation

◆ fair_queue()

seastar::fair_queue::fair_queue ( fair_group shared,
config  cfg 

Constructs a fair queue with configuration parameters cfg.

cfgan instance of the class config

Member Function Documentation

◆ notify_request_finished()

void seastar::fair_queue::notify_request_finished ( fair_queue_entry::capacity_t  cap)

Notifies that ont request finished

descan instance of fair_queue_ticket structure describing the request that just finished.

◆ queue()

void seastar::fair_queue::queue ( class_id  c,
fair_queue_entry ent 

Queue the entry ent through this class' fair_queue

The user of this interface is supposed to call notify_requests_finished when the request finishes executing - regardless of success or failure.

◆ register_priority_class()

void seastar::fair_queue::register_priority_class ( class_id  c,
uint32_t  shares 

Registers a priority class against this fair queue.

shareshow many shares to create this class with

◆ resources_currently_executing()

fair_queue_ticket seastar::fair_queue::resources_currently_executing ( ) const
the amount of resources (weight, size) currently executing

◆ resources_currently_waiting()

fair_queue_ticket seastar::fair_queue::resources_currently_waiting ( ) const
how much resources (weight, size) are currently queued for all classes.

◆ unregister_priority_class()

void seastar::fair_queue::unregister_priority_class ( class_id  c)

Unregister a priority class.

It is illegal to unregister a priority class that still have pending requests.

The documentation for this class was generated from the following file: