2
3
6
7
8
9
10
11
15#include <so_5/priority.hpp>
16#include <so_5/exception.hpp>
17#include <so_5/ret_code.hpp>
22#if defined(__clang__
) && (__clang_major__
>= 16
)
23#pragma clang diagnostic push
24#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
103 "quote for a priority cannot be zero" );
115#if defined(__clang__
) && (__clang_major__
>= 16
)
116#pragma clang diagnostic pop
priority_t so_priority() const noexcept
Get the priority of the agent.
void so_bind_to_dispatcher(event_queue_t &queue) noexcept
Binding agent to the dispatcher.
Container for storing parameters for MPSC queue.
const lock_factory_t & lock_factory() const
Getter for lock factory.
queue_params_t & operator=(queue_params_t &&o) noexcept
Move operator.
friend void swap(queue_params_t &a, queue_params_t &b) noexcept
Alias for namespace with traits of event queue.
disp_params_t & set_queue_params(queue_traits::queue_params_t p)
Setter for queue parameters.
queue_traits::queue_params_t m_queue_params
Queue parameters.
const queue_traits::queue_params_t & queue_params() const
Getter for queue parameters.
disp_params_t & tune_queue_params(L tunner)
Tuner for queue parameters.
disp_params_t()
Default constructor.
friend void swap(disp_params_t &a, disp_params_t &b) noexcept
A handle for prio_one_thread::strictly_ordered dispatcher.
disp_binder_shptr_t m_binder
Binder for the dispatcher.
void reset() noexcept
Drop the content of handle.
bool empty() const noexcept
Is this handle empty?
bool operator!() const noexcept
Does this handle contain a reference to dispatcher?
dispatcher_handle_t(disp_binder_shptr_t binder) noexcept
operator bool() const noexcept
Is this handle empty?
disp_binder_shptr_t binder() const noexcept
Get a binder for that dispatcher.
dispatcher_handle_t() noexcept=default
A demand queue for dispatcher with one common working thread and round-robin processing of prioritise...
void agent_unbound(priority_t priority)
Notification about detachment of an agent from the queue.
demand_queue_t(queue_traits::lock_unique_ptr_t lock, const quotes_t "es)
void agent_bound(priority_t priority)
Notification about attachment of yet another agent to the queue.
event_queue_t & event_queue_by_priority(priority_t priority)
Get queue for the priority specified.
void stop()
Set the shutdown signal.
static dispatcher_handle_t make(disp_binder_shptr_t binder) noexcept
Data source for run-time monitoring of whole dispatcher.
stats::prefix_t m_base_prefix
Basic prefix for data sources.
disp_data_source_t(const std::string_view name_base, outliving_reference_t< dispatcher_template_t > disp)
outliving_reference_t< dispatcher_template_t > m_dispatcher
Dispatcher to work with.
void distribute_value_for_priority(const mbox_t &mbox, priority_t priority, std::size_t quote, std::size_t agents_count, std::size_t demands_count)
void distribute(const mbox_t &mbox) override
Send appropriate notification about the current value.
void undo_preallocation(agent_t &) noexcept override
Undo resources allocation.
dispatcher_template_t(outliving_reference_t< environment_t > env, const std::string_view name_base, disp_params_t params, const quotes_t "es)
void preallocate_resources(agent_t &) override
Allocate resources in dispatcher for new agent.
void unbind(agent_t &agent) noexcept override
Unbind agent from dispatcher.
void bind(agent_t &agent) noexcept override
Bind agent to dispatcher.
~dispatcher_template_t() noexcept override
stats::auto_registered_source_holder_t< disp_data_source_t > m_data_source
Data source for run-time monitoring.
Work_Thread m_work_thread
Working thread for the dispatcher.
demand_queue_t m_demand_queue
Demand queue for the dispatcher.
A storage of quotes for priorities.
size_t query(priority_t prio) const
Get the quote for a priority.
quotes_t & set(priority_t prio, std::size_t quote)
Set a new quote for a priority.
std::size_t m_quotes[so_5::prio::total_priorities_count]
Quotes for every priority.
quotes_t(std::size_t default_value)
static void ensure_quote_not_zero(std::size_t value)
so_5::stats::work_thread_activity_stats_t take_activity_stats()
so_5::current_thread_id_t thread_id() const
Mixin with thread activity tracking flag.
friend void swap(work_thread_activity_tracking_flag_mixin_t &a, work_thread_activity_tracking_flag_mixin_t &b) noexcept
Mixin that holds optional work thread factory.
friend void swap(work_thread_factory_mixin_t &a, work_thread_factory_mixin_t &b) noexcept
Interface for dispatcher binders.
stats::repository_t & stats_repository()
Access to repository of data sources for run-time monitoring.
Helper class for indication of long-lived reference via its type.
A holder for data-souce that should be automatically registered and deregistered in registry.
A type for storing prefix of data_source name.
constexpr const char * c_str() const noexcept
Access to prefix value.
prefix_t(const std::string &value) noexcept(noexcept(value.c_str()))
Initializing constructor.
An interface of data source.
#define SO_5_THROW_EXCEPTION(error_code, desc)
Various stuff related to MPSC event queue implementation and tuning.
void send_thread_activity_stats(const so_5::mbox_t &, const stats::prefix_t &, so_5::disp::prio_one_thread::reuse::work_thread_no_activity_tracking_t< demand_queue_t > &)
Implementation details for dispatcher with round-robin policy of handling prioritized events.
Dispatcher which handles events of different priorities in round-robin maner.
dispatcher_handle_t make_dispatcher(environment_t &env, const quotes_t "es)
Create an instance of quoted_round_robin dispatcher.
dispatcher_handle_t make_dispatcher(environment_t &env, const std::string_view data_sources_name_base, const quotes_t "es)
Create an instance of quoted_round_robin dispatcher.
SO_5_FUNC dispatcher_handle_t make_dispatcher(environment_t &env, const std::string_view data_sources_name_base, const quotes_t "es, disp_params_t params)
Create an instance of quoted_round_robin dispatcher.
Reusable code for dispatchers with one working thread for events of all priorities.
Dispatcher with one working thread for events of all priorities.
Reusable components for dispatchers.
work_thread_holder_t acquire_work_thread(const work_thread_factory_mixin_t< Params > ¶ms, environment_t &env)
Helper function for acquiring a new worker thread from an appropriate work thread factory.
so_5::stats::prefix_t make_disp_prefix(const std::string_view disp_type, const std::string_view data_sources_name_base, const void *disp_this_pointer)
Create basic prefix for dispatcher data source names.
std::unique_ptr< Disp_Iface_Type > make_actual_dispatcher(outliving_reference_t< environment_t > env, const std::string_view name_base, Disp_Params_Type disp_params, Args &&...args)
Helper function for creation of dispatcher instance with respect to work thread activity tracking fla...
Helpers for working with priorities.
const unsigned int total_priorities_count
Total count of priorities.
Declarations of messages used by run-time monitoring and statistics.
Predefined suffixes of data-sources.
SO_5_FUNC suffix_t agent_count()
Suffix for data source with count of agents bound to some entity.
SO_5_FUNC suffix_t work_thread_queue_size()
Suffix for data source with count of demands in a working thread event queue.
SO_5_FUNC suffix_t work_thread_activity()
Suffix for data source with work thread activity statistics.
SO_5_FUNC suffix_t demand_quote()
Suffix for data source with size of quote for demands processing.
All stuff related to run-time monitoring and statistics.
Private part of message limit implementation.
std::size_t to_size_t(priority_t priority)
Helper function for conversion from priority to size_t.
priority_t
Definition of supported priorities.
const int rc_priority_quote_illegal_value
Illegal value of quote for a priority.
void send(Target &&to, Args &&... args)
A utility function for creating and delivering a message or a signal.
outliving_reference_t< T > outliving_mutable(T &r)
Make outliving_reference wrapper for mutable reference.
Statistic about one subqueue.
std::size_t m_agents_count
std::size_t m_demands_count
A message with value of some quantity.
Information about one work thread activity.