SObjectizer  5.8
Loading...
Searching...
No Matches
agent_ptr_compare.hpp
Go to the documentation of this file.
1/*
2 SObjectizer 5.
3*/
4
5/*!
6 * \file
7 * \brief A special comparison for agent pointers.
8 *
9 * \since v.5.5.8
10 */
11
12#pragma once
13
14#include <so_5/fwd.hpp>
15
16#include <functional>
17
18namespace so_5 {
19
20namespace impl {
21
22/*!
23 * \brief A special comparison for agent pointers with respect to
24 * agent's priorities.
25 *
26 * \retval true if \a a is less than \a b.
27 *
28 * \since v.5.5.8
29 */
30[[nodiscard]]
31inline bool
32special_agent_ptr_compare( const agent_t & a, const agent_t & b ) noexcept
33 {
34 // Use std::less for compare pointers.
35 // NOTE: it's UB to compare pointers that do not belong to the same array.
36 using ptr_comparator_t = std::less< const agent_t * >;
37
38 auto p1 = a.so_priority();
39 auto p2 = b.so_priority();
40
41 // NOTE: there should be inversion -- agent with higher
42 // priority must be first.
43 return ( p1 > p2 || (p1 == p2 && ptr_comparator_t{}( &a, &b ) ) );
44 }
45
46} /* namespace impl */
47
48} /* namespace so_5 */
A base class for agents.
Definition agent.hpp:673
void so_initiate_agent_definition()
A correct initiation of so_define_agent method call.
Definition agent.cpp:963
void shutdown_agent() noexcept
Agent shutdown deriver.
Definition agent.cpp:1163
void bind_to_coop(coop_t &coop)
Bind agent to the cooperation.
Definition agent.cpp:1157
priority_t so_priority() const noexcept
Get the priority of the agent.
Definition agent.hpp:2600
Container for cooperation deregistration notificators.
Definition coop.hpp:197
void call_all(environment_t &env, const coop_handle_t &coop, const coop_dereg_reason_t &reason) const noexcept
Call all notificators.
Definition coop.cpp:38
It's a kind of strong typedef for coop's deregistration reason.
Definition coop.hpp:80
Type of smart handle for a cooperation.
Container for cooperation registration notificators.
Definition coop.hpp:129
void call_all(environment_t &env, const coop_handle_t &coop) const noexcept
Call all notificators.
Definition coop.cpp:26
Agent cooperation.
Definition coop.hpp:389
environment_t & environment() const noexcept
Access to SO Environment for which cooperation is bound.
Definition coop.hpp:453
registration_status_t m_registration_status
The registration status of cooperation.
Definition coop.hpp:1092
void decrement_usage_count() noexcept
Decrement usage count for the coop.
Definition coop.hpp:1224
void deregister(int reason) noexcept
Deregister the cooperation with the specified reason.
Definition coop.hpp:907
exception_reaction_t m_exception_reaction
A reaction to non-handled exception.
Definition coop.hpp:1121
registration_status_t
Registration status.
Definition coop.hpp:956
@ deregistration_in_final_stage
Deregistration of the coop is in the final stage.
@ coop_registered
Cooperation is registered.
@ coop_deregistering
Cooperation is in deregistration process.
coop_dereg_reason_t m_dereg_reason
Deregistration reason.
Definition coop.hpp:1110
void increment_usage_count() noexcept
Increment usage count for the coop.
Definition coop.hpp:1196
Interface for dispatcher binders.
SObjectizer Environment.
exception_reaction_t exception_reaction() const noexcept
An exception reaction for the whole SO Environment.
The base class for all SObjectizer exceptions.
Definition exception.hpp:34
A helper for coop's deregistration procedure.
Definition coop.cpp:415
deregistration_performer_t(coop_t &coop, coop_dereg_reason_t reason) noexcept
Definition coop.cpp:465
registration_performer_t(coop_t &coop) noexcept
Definition coop.cpp:387
An internal class with real implementation of coop's logic.
Definition coop.hpp:249
static void destroy_content(coop_t &coop) noexcept
Perform all necessary cleanup actions for coop.
Definition coop.cpp:54
static void do_final_deregistration_actions(coop_t &coop)
Perform final deregistration actions for an coop.
Definition coop.cpp:501
static exception_reaction_t exception_reaction(const coop_t &coop) noexcept
Get exception reaction for coop.
Definition coop.cpp:157
static void do_remove_child(coop_t &parent, coop_t &child) noexcept
Perform removement of a child coop.
Definition coop.cpp:560
static void do_decrement_reference_count(coop_t &coop) noexcept
Do decrement reference count for a coop.
Definition coop.cpp:174
static void do_deregistration_specific_actions(coop_t &coop, coop_dereg_reason_t reason) noexcept
Perform actions related to the deregistration of coop.
Definition coop.cpp:493
static void do_registration_specific_actions(coop_t &coop)
Perform actions related to the registration of coop.
Definition coop.cpp:405
static void do_add_agent(coop_t &coop, agent_ref_t agent_ref)
Add agent to cooperation.
Definition coop.cpp:79
internal_agent_iface_t(agent_t &agent) noexcept
disp_binder_t & query_disp_binder() const
Getter for disp_binder.
void drop_disp_binder() noexcept
Helper method that drops pointer to disp_binder.
void set_disp_binder(disp_binder_shptr_t binder)
Setter for disp_binder.
A helper class for accessing the functionality of environment-class which is specific for SObjectizer...
Template class for smart reference wrapper on the atomic_refcounted_t.
#define SO_5_THROW_EXCEPTION(error_code, desc)
Definition exception.hpp:74
Enumeration of cooperation deregistration reasons.
Definition coop.hpp:39
const int parent_deregistration
Deregistration because parent cooperation deregistration.
Definition coop.hpp:52
Some reusable and low-level classes/functions which can be used in public header files.
void do_add_notificator_to(intrusive_ptr_t< C > &to, N notificator)
Helper function for notificator addition.
Definition coop.cpp:121
Details of SObjectizer run-time implementations.
Definition agent.cpp:905
bool special_agent_ptr_compare(const agent_t &a, const agent_t &b) noexcept
A special comparison for agent pointers with respect to agent's priorities.
Private part of message limit implementation.
Definition agent.cpp:33
exception_reaction_t
A reaction of SObjectizer to an exception from agent event.
Definition agent.hpp:65
@ inherit_exception_reaction
Exception reaction should be inherited from SO Environment.
Definition agent.hpp:81