Seastar
High performance C++ framework for concurrent servers
|
Go to the documentation of this file.
25 #include <seastar/core/sstring.hh>
26 #include <seastar/core/function_traits.hh>
27 #include <seastar/util/concepts.hh>
33 constexpr
unsigned max_scheduling_groups() {
return 16; }
35 #if SEASTAR_API_LEVEL < 6
36 #define SEASTAR_ELLIPSIS ...
37 template <
typename SEASTAR_ELLIPSIS T>
39 #define SEASTAR_ELLIPSIS
40 template <
typename T =
void>
46 class scheduling_group;
47 class scheduling_group_key;
52 unsigned scheduling_group_index(scheduling_group sg) noexcept;
53 scheduling_group scheduling_group_from_index(
unsigned index) noexcept;
55 unsigned long scheduling_group_key_id(scheduling_group_key) noexcept;
58 T* scheduling_group_get_specific_ptr(scheduling_group sg, scheduling_group_key key) noexcept;
159 unsigned long id() const noexcept {
162 friend class reactor;
196 template<
typename ConstructorType,
typename Tuple,
size_t...Idx>
197 void apply_constructor(
void* pre_alocated_mem, Tuple args, std::index_sequence<Idx...> idx_seq) {
198 new (pre_alocated_mem) ConstructorType(std::get<Idx>(args)...);
212 template <
typename T,
typename... ConstructorArgs>
213 scheduling_group_key_config
218 sgkc.
constructor = [args = std::make_tuple(args...)] (
void* p) {
219 internal::apply_constructor<T>(p, args, std::make_index_sequence<
sizeof...(ConstructorArgs)>());
222 static_cast<T*
>(p)->~T();
258 bool active() const noexcept;
259 const sstring& name() const noexcept;
262 bool is_main() const noexcept {
return _id == 0; }
271 return *internal::scheduling_group_get_specific_ptr<T>(*
this, key);
290 friend unsigned internal::scheduling_group_index(
scheduling_group sg) noexcept;
291 friend scheduling_group internal::scheduling_group_from_index(
unsigned index) noexcept;
293 template<
typename SpecificValType,
typename Mapper,
typename Reducer,
typename Initial>
294 SEASTAR_CONCEPT( requires requires(SpecificValType specific_val, Mapper mapper, Reducer reducer, Initial initial) {
295 {reducer(initial, mapper(specific_val))} -> std::convertible_to<Initial>;
297 friend future<
typename function_traits<Reducer>::return_type>
300 template<
typename SpecificValType,
typename Reducer,
typename Initial>
301 SEASTAR_CONCEPT( requires requires(SpecificValType specific_val, Reducer reducer, Initial initial) {
302 {reducer(initial, specific_val)} -> std::convertible_to<Initial>;
304 friend future<
typename function_traits<Reducer>::return_type>
315 scheduling_group_index(scheduling_group sg) noexcept {
321 scheduling_group_from_index(
unsigned index) noexcept {
322 return scheduling_group(index);
327 current_scheduling_group_ptr() noexcept {
329 static thread_local scheduling_group sg;
340 return *internal::current_scheduling_group_ptr();
345 default_scheduling_group() noexcept {
346 return scheduling_group();
351 scheduling_group::active() const noexcept {
362 return seastar::internal::scheduling_group_index(sg);
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:174
Seastar API namespace.
Definition: abort_on_ebadf.hh:24
friend future rename_scheduling_group(scheduling_group sg, sstring new_name) noexcept
Definition: reactor.hh:187
Definition: scheduling.hh:150
Definition: scheduling.hh:112
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:140
size_t allocation_size
The allocation size for the value (usually: sizeof(T))
Definition: scheduling.hh:130
future rename_scheduling_group(scheduling_group sg, sstring new_name) noexcept
scheduling_group_key_config(const std::type_info &type_info)
Definition: scheduling.hh:127
future< scheduling_group > create_scheduling_group(sstring name, float shares) noexcept
std::function< void(void *)> destructor
Definition: scheduling.hh:139
friend T & scheduling_group_get_specific(scheduling_group_key key) noexcept
Definition: scheduling_specific.hh:110
future< scheduling_group_key > scheduling_group_key_create(scheduling_group_key_config cfg) noexcept
T & get_specific(scheduling_group_key key) noexcept
Definition: scheduling.hh:270
future destroy_scheduling_group(scheduling_group sg) noexcept
scheduling_group current_scheduling_group() noexcept
Returns the current scheduling group.
Definition: scheduling.hh:339
size_t alignment
The required alignment of the value (usually: alignof(T))
Definition: scheduling.hh:132
friend future< scheduling_group > create_scheduling_group(sstring name, float shares) noexcept
T & scheduling_group_get_specific(scheduling_group sg, scheduling_group_key key)
Definition: scheduling_specific.hh:94
scheduling_group_key_config()
Definition: scheduling.hh:116
std::function< void(void *)> constructor
A function that will be called for each newly allocated value.
Definition: scheduling.hh:136
A representation of a possibly not-yet-computed value.
Definition: future.hh:1337
friend future< scheduling_group_key > scheduling_group_key_create(scheduling_group_key_config cfg) noexcept
scheduling_group_key(const scheduling_group_key &) noexcept=default
The only user allowed operation on a key is copying.
constexpr scheduling_group() noexcept
Creates a scheduling_group object denoting the default group.
Definition: scheduling.hh:257
friend future destroy_scheduling_group(scheduling_group sg) noexcept
scheduling_group_key_config make_scheduling_group_key_config(ConstructorArgs... args)
Definition: scheduling.hh:214
void set_shares(float shares) noexcept
std::type_index type_index
Holds the type information for debug mode runtime validation.
Definition: scheduling.hh:134
Identifies function calls that are accounted as a group.
Definition: scheduling.hh:251