30#include <seastar/core/sstring.hh>
31#include <seastar/core/function_traits.hh>
32#include <seastar/util/modules.hh>
38SEASTAR_MODULE_EXPORT_BEGIN
39constexpr unsigned max_scheduling_groups() {
return SEASTAR_SCHEDULING_GROUPS_COUNT; }
41template <
typename T =
void>
46class scheduling_group;
47class scheduling_group_key;
49using sched_clock = std::chrono::steady_clock;
50SEASTAR_MODULE_EXPORT_END
55unsigned scheduling_group_index(scheduling_group sg)
noexcept;
56scheduling_group scheduling_group_from_index(
unsigned index)
noexcept;
58unsigned long scheduling_group_key_id(scheduling_group_key)
noexcept;
61T* scheduling_group_get_specific_ptr(scheduling_group sg, scheduling_group_key key)
noexcept;
65SEASTAR_MODULE_EXPORT_BEGIN
192 unsigned long id() const noexcept {
204SEASTAR_MODULE_EXPORT_END
229template<
typename ConstructorType,
typename Tuple,
size_t...Idx>
230void apply_constructor(
void* pre_alocated_mem, Tuple args, std::index_sequence<Idx...>) {
231 new (pre_alocated_mem) ConstructorType(std::get<Idx>(args)...);
234SEASTAR_MODULE_EXPORT_BEGIN
246template <
typename T,
typename... ConstructorArgs>
247scheduling_group_key_config
252 sgkc.
constructor = [args = std::make_tuple(args...)] (
void* p) {
253 internal::apply_constructor<T>(p, args, std::make_index_sequence<
sizeof...(ConstructorArgs)>());
256 static_cast<T*
>(p)->~T();
292 bool active() const noexcept;
293 const sstring& name() const noexcept;
294 const sstring& short_name() const noexcept;
297 bool is_main() const noexcept {
return _id == 0; }
298 bool is_at_exit() const noexcept {
return _id == 1; }
307 return *internal::scheduling_group_get_specific_ptr<T>(*
this, key);
329#if SEASTAR_API_LEVEL >= 7
344 friend unsigned internal::scheduling_group_index(
scheduling_group sg)
noexcept;
345 friend scheduling_group internal::scheduling_group_from_index(
unsigned index)
noexcept;
347 template<
typename SpecificValType,
typename Mapper,
typename Reducer,
typename Initial>
348 requires requires(SpecificValType specific_val, Mapper mapper, Reducer reducer, Initial initial) {
349 {reducer(initial, mapper(specific_val))} -> std::convertible_to<Initial>;
351 friend future<typename function_traits<Reducer>::return_type>
354 template<
typename SpecificValType,
typename Reducer,
typename Initial>
355 requires requires(SpecificValType specific_val, Reducer reducer, Initial initial) {
356 {reducer(initial, specific_val)} -> std::convertible_to<Initial>;
358 friend future<typename function_traits<Reducer>::return_type>
365SEASTAR_MODULE_EXPORT_END
370scheduling_group_index(scheduling_group sg)
noexcept {
376scheduling_group_from_index(
unsigned index)
noexcept {
377 return scheduling_group(index);
380#ifdef SEASTAR_BUILD_SHARED_LIBS
382current_scheduling_group_ptr() noexcept;
386current_scheduling_group_ptr() noexcept {
388 static thread_local scheduling_group sg;
395SEASTAR_MODULE_EXPORT_BEGIN
400 return *internal::current_scheduling_group_ptr();
405default_scheduling_group() noexcept {
406 return scheduling_group();
409SEASTAR_MODULE_EXPORT_END
413scheduling_group::active() const noexcept {
425 return seastar::internal::scheduling_group_index(sg);
A representation of a possibly not-yet-computed value.
Definition: future.hh:1240
Definition: reactor.hh:155
Definition: scheduling.hh:183
friend future< scheduling_group_key > scheduling_group_key_create(scheduling_group_key_config cfg) noexcept
friend T & scheduling_group_get_specific(scheduling_group_key key) noexcept
Definition: scheduling_specific.hh:120
scheduling_group_key(const scheduling_group_key &) noexcept=default
The only user allowed operation on a key is copying.
Identifies function calls that are accounted as a group.
Definition: scheduling.hh:285
float get_shares() const noexcept
constexpr scheduling_group() noexcept
Creates a scheduling_group object denoting the default group.
Definition: scheduling.hh:291
friend future rename_scheduling_group(scheduling_group sg, sstring new_name, sstring new_shortname) noexcept
friend future destroy_scheduling_group(scheduling_group sg) noexcept
future update_io_bandwidth(uint64_t bandwidth) const
Updates the current IO bandwidth for a given scheduling group.
friend future< scheduling_group > create_scheduling_group(sstring name, sstring shortname, float shares) noexcept
void set_shares(float shares) noexcept
friend future< typename function_traits< Reducer >::return_type > reduce_scheduling_group_specific(Reducer reducer, Initial initial_val, scheduling_group_key key)
Definition: scheduling_specific.hh:184
friend future< typename function_traits< Reducer >::return_type > map_reduce_scheduling_group_specific(Mapper mapper, Reducer reducer, Initial initial_val, scheduling_group_key key)
Definition: scheduling_specific.hh:150
T & get_specific(scheduling_group_key key) noexcept
Definition: scheduling.hh:306
Seastar API namespace.
Definition: abort_on_ebadf.hh:26
scheduling_group current_scheduling_group() noexcept
Returns the current scheduling group.
Definition: scheduling.hh:399
T & scheduling_group_get_specific(scheduling_group sg, scheduling_group_key key)
Definition: scheduling_specific.hh:104
future destroy_scheduling_group(scheduling_group sg) noexcept
future rename_scheduling_group(scheduling_group sg, sstring new_name) noexcept
future< scheduling_group > create_scheduling_group(sstring name, float shares) noexcept
scheduling_group_key_config make_scheduling_group_key_config(ConstructorArgs... args)
Definition: scheduling.hh:248
future< scheduling_group_key > scheduling_group_key_create(scheduling_group_key_config cfg) noexcept
Definition: scheduling.hh:143
size_t allocation_size
The allocation size for the value (usually: sizeof(T))
Definition: scheduling.hh:161
std::function< void(void *)> constructor
A function that will be called for each newly allocated value.
Definition: scheduling.hh:167
std::function< void(void *)> rename
A function that will be called for each value after the scheduling group is renamed.
Definition: scheduling.hh:169
std::type_index type_index
Holds the type information for debug mode runtime validation.
Definition: scheduling.hh:165
scheduling_group_key_config()
Definition: scheduling.hh:147
size_t alignment
The required alignment of the value (usually: alignof(T))
Definition: scheduling.hh:163
scheduling_group_key_config(const std::type_info &type_info)
Definition: scheduling.hh:158
std::function< void(void *)> destructor
Definition: scheduling.hh:172