SObjectizer  5.8
Loading...
Searching...
No Matches
so_5::event_queue_hook_t Class Referenceabstract

Interface of event_queue_hook object. More...

#include <event_queue_hook.hpp>

Inheritance diagram for so_5::event_queue_hook_t:
so_5::anonymous_namespace{environment.cpp}::default_event_queue_hook_t so_5::experimental::testing::v1::impl::special_event_queue_hook_t

Public Member Functions

 event_queue_hook_t ()=default
 
virtual ~event_queue_hook_t ()=default
 
virtual event_queue_ton_bind (agent_t *agent, event_queue_t *original_queue) noexcept=0
 A reaction to binding of an agent to some event_queue.
 
virtual void on_unbind (agent_t *agent, event_queue_t *queue) noexcept=0
 A reaction to unbinding of an agent from some event_queue.
 

Static Public Member Functions

static void default_deleter (event_queue_hook_t *what) noexcept
 An implementation of deleter that use operator delete for destroying object of type event_queue_hook.
 
static void noop_deleter (event_queue_hook_t *) noexcept
 An implementation of no-op deleter.
 

Private Member Functions

 event_queue_hook_t (const event_queue_hook_t &)=delete
 
 event_queue_hook_t (event_queue_hook_t &&)=delete
 
event_queue_hook_toperator= (const event_queue_hook_t &)=delete
 
event_queue_hook_toperator= (event_queue_hook_t &&)=delete
 

Detailed Description

Interface of event_queue_hook object.

Since v.5.5.24 there is a new mechanism for customization of SObjectizer: hook for event_queue. Such hooks allows to replace an original event_queue provided by a dispatcher to some custom version of event_queue. That custom version can do some additional stuff, for example, collect some stats about demands.

This class describes an interface of event_queue_hook. The interface contains the following methods:

  • on_bind(). This method will be called by every agent in SObjectizer when agent is being bound to a dispatcher. This method can be used for replacing an original event_queue by custom one;
  • on_unbind(). This method will be called by every agent when agent is being unbound from the dispatcher. This method should be used for releasing any resources allocated for a custom queue created or used in on_bind() method.
Since
v.5.5.24

Definition at line 62 of file event_queue_hook.hpp.

Constructor & Destructor Documentation

◆ event_queue_hook_t() [1/3]

so_5::event_queue_hook_t::event_queue_hook_t ( const event_queue_hook_t & )
privatedelete

◆ event_queue_hook_t() [2/3]

so_5::event_queue_hook_t::event_queue_hook_t ( event_queue_hook_t && )
privatedelete

◆ event_queue_hook_t() [3/3]

so_5::event_queue_hook_t::event_queue_hook_t ( )
default

◆ ~event_queue_hook_t()

virtual so_5::event_queue_hook_t::~event_queue_hook_t ( )
virtualdefault

Member Function Documentation

◆ default_deleter()

void so_5::event_queue_hook_t::default_deleter ( event_queue_hook_t * what)
staticnoexcept

An implementation of deleter that use operator delete for destroying object of type event_queue_hook.

Pointer to this method is intended to be used with event_queue_hook_unique_ptr_t. For example:

class my_hook final : public so_5::event_queue_hook_t {
...
};
...
so_5::event_queue_hook_unique_ptr_t hook_ptr{
new my_hook(...),
...
so_5::launch(
[](so_5::environment_t & env) {...},
params.event_queue_hook(std::move(hook_ptr));
});
Parameters for the SObjectizer Environment initialization.
SObjectizer Environment.
Interface of event_queue_hook object.
static void default_deleter(event_queue_hook_t *what) noexcept
An implementation of deleter that use operator delete for destroying object of type event_queue_hook.

Definition at line 19 of file event_queue_hook.cpp.

◆ noop_deleter()

void so_5::event_queue_hook_t::noop_deleter ( event_queue_hook_t * )
staticnoexcept

An implementation of no-op deleter.

This method do nothing. It is intended to be used with objects those not to be deleted by operator delete. For example:

class my_hook final : public so_5::event_queue_hook_t {
...
};
...
// Note! This object is created on stack.
my_hook hook{...};
...
so_5::launch(
[](so_5::environment_t & env) {...},
params.event_queue_hook(
&hook,
});
static void noop_deleter(event_queue_hook_t *) noexcept
An implementation of no-op deleter.
std::unique_ptr< event_queue_hook_t, event_queue_hook_deleter_fnptr_t > event_queue_hook_unique_ptr_t
Alias for unique pointer to event_queue_hook.

Definition at line 25 of file event_queue_hook.cpp.

◆ on_bind()

virtual event_queue_t * so_5::event_queue_hook_t::on_bind ( agent_t * agent,
event_queue_t * original_queue )
nodiscardpure virtualnoexcept

A reaction to binding of an agent to some event_queue.

This method can return original_queue or a pointer to a different queue. The agent must use the value returned.

Parameters
agentAn agent that is being bound to some event_queue.
original_queueAn event_queue created for that agent by a dispatcher.

Implemented in so_5::anonymous_namespace{environment.cpp}::default_event_queue_hook_t, and so_5::experimental::testing::v1::impl::special_event_queue_hook_t.

◆ on_unbind()

virtual void so_5::event_queue_hook_t::on_unbind ( agent_t * agent,
event_queue_t * queue )
pure virtualnoexcept

A reaction to unbinding of an agent from some event_queue.

This method must be called by an agent even if the previous call to on_bind() returned pointer to the original queue.

Parameters
agentAn agent that is being bound to some event_queue.
queueThe pointer returned by previous call to on_bind.

Implemented in so_5::anonymous_namespace{environment.cpp}::default_event_queue_hook_t, and so_5::experimental::testing::v1::impl::special_event_queue_hook_t.

◆ operator=() [1/2]

event_queue_hook_t & so_5::event_queue_hook_t::operator= ( const event_queue_hook_t & )
privatedelete

◆ operator=() [2/2]

event_queue_hook_t & so_5::event_queue_hook_t::operator= ( event_queue_hook_t && )
privatedelete

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