Класс propagator_blockpropagator_block Class
Класс propagator_block
— это абстрактный базовый класс для блоков сообщений, которые являются одновременно блоками источников и целевыми блоками.The propagator_block
class is an abstract base class for message blocks that are both a source and target. Он объединяет функциональные возможности обоих классов, source_block
и target_block
.It combines the functionality of both the source_block
and target_block
classes.
СинтаксисSyntax
template<class _TargetLinkRegistry, class _SourceLinkRegistry, class _MessageProcessorType = ordered_message_processor<typename _TargetLinkRegistry::type::type>>
class propagator_block : public source_block<_TargetLinkRegistry,
_MessageProcessorType>,
public ITarget<typename _SourceLinkRegistry::type::source_type>;
ПараметрыParameters
_TargetLinkRegistry_TargetLinkRegistry
Реестр ссылок, используемый для хранения целевых ссылок.The link registry to be used for holding the target links.
_SourceLinkRegistry_SourceLinkRegistry
Реестр ссылок, используемый для хранения исходных ссылок.The link registry to be used for holding the source links.
_MessageProcessorType_MessageProcessorType
Тип процессора для обработки сообщений.The processor type for message processing.
ЭлементыMembers
Общедоступные определения типовPublic Typedefs
ИмяName | ОписаниеDescription |
---|---|
source_iterator |
Тип итератора для source_link_manager этого объекта propagator_block .The type of the iterator for the source_link_manager for this propagator_block . |
Открытые конструкторыPublic Constructors
nameName | ОписаниеDescription |
---|---|
propagator_blockpropagator_block | Формирует объект propagator_block .Constructs a propagator_block object. |
Деструктор ~ propagator_block~propagator_block Destructor | Уничтожает объект propagator_block .Destroys a propagator_block object. |
Открытые методыPublic Methods
nameName | ОписаниеDescription |
---|---|
распространенияpropagate | Асинхронно передает сообщение из исходного блока в этот целевой блок.Asynchronously passes a message from a source block to this target block. |
sendsend | Синхронно инициирует сообщение для этого блока.Synchronously initiates a message to this block. Вызывается ISource блоком.Called by an ISource block. По завершении этой функции сообщение уже будет распространено в блок.When this function completes, the message will already have propagated into the block. |
Защищенные методыProtected Methods
ИмяName | ОписаниеDescription |
---|---|
decline_incoming_messagesdecline_incoming_messages | Указывает блоку, что следует отклонять новые сообщения.Indicates to the block that new messages should be declined. |
initialize_source_and_targetinitialize_source_and_target | Инициализирует базовый объект.Initializes the base object. В частности, необходимо message_processor инициализировать объект.Specifically, the message_processor object needs to be initialized. |
link_sourcelink_source | Связывает указанный блок источника с этим propagator_block объектом.Links a specified source block to this propagator_block object. |
process_input_messagesprocess_input_messages | Обработка входных сообщений.Process input messages. Это полезно только для блоков распространения, которые являются производными от source_block (переопределяет source_block::p rocess_input_messages.)This is only useful for propagator blocks, which derive from source_block (Overrides source_block::process_input_messages.) |
propagate_messagepropagate_message | При переопределении в производном классе этот метод асинхронно передает сообщение из ISource блока в этот propagator_block объект.When overridden in a derived class, this method asynchronously passes a message from an ISource block to this propagator_block object. Он вызывается propagate методом при вызове из исходного блока.It is invoked by the propagate method, when called by a source block. |
register_filterregister_filter | Регистрирует метод фильтра, который будет вызываться для каждого полученного сообщения.Registers a filter method that will be invoked on every received message. |
remove_network_linksremove_network_links | Удаляет все связи исходной и целевой сетей из этого propagator_block объекта.Removes all the source and target network links from this propagator_block object. |
send_messagesend_message | При переопределении в производном классе этот метод синхронно передает сообщение из ISource блока в этот propagator_block объект.When overridden in a derived class, this method synchronously passes a message from an ISource block to this propagator_block object. Он вызывается send методом при вызове из исходного блока.It is invoked by the send method, when called by a source block. |
unlink_sourceunlink_source | Отменяет связь указанного исходного блока с этим propagator_block объектом.Unlinks a specified source block from this propagator_block object. |
unlink_sourcesunlink_sources | Отменяет связь со всеми исходными блоками этого propagator_block объекта.Unlinks all source blocks from this propagator_block object. (Переопределяет метод ITarget:: unlink_sources.)(Overrides ITarget::unlink_sources.) |
КомментарииRemarks
Чтобы избежать множественного наследования, propagator_block
класс наследует от source_block
класса и ITarget
абстрактного класса.To avoid multiple inheritance, the propagator_block
class inherits from the source_block
class and ITarget
abstract class. Большая часть функциональных возможностей в target_block
классе реплицируется здесь.Most of the functionality in the target_block
class is replicated here.
Иерархия наследованияInheritance Hierarchy
propagator_block
ТребованияRequirements
Заголовок: agents.hHeader: agents.h
Пространство имен: параллелизмNamespace: concurrency
decline_incoming_messagesdecline_incoming_messages
Указывает блоку, что следует отклонять новые сообщения.Indicates to the block that new messages should be declined.
void decline_incoming_messages();
КомментарииRemarks
Этот метод вызывается деструктором, чтобы гарантировать отклонение новых сообщений в процессе уничтожения.This method is called by the destructor to ensure that new messages are declined while destruction is in progress.
initialize_source_and_targetinitialize_source_and_target
Инициализирует базовый объект.Initializes the base object. В частности, необходимо message_processor
инициализировать объект.Specifically, the message_processor
object needs to be initialized.
void initialize_source_and_target(
_Inout_opt_ Scheduler* _PScheduler = NULL,
_Inout_opt_ ScheduleGroup* _PScheduleGroup = NULL);
ПараметрыParameters
_PScheduler_PScheduler
Планировщик, который будет использоваться для планирования задач.The scheduler to be used for scheduling tasks.
_PScheduleGroup_PScheduleGroup
Группа расписаний, которая будет использоваться для планирования задач.The schedule group to be used for scheduling tasks.
link_sourcelink_source
Связывает указанный блок источника с этим propagator_block
объектом.Links a specified source block to this propagator_block
object.
virtual void link_source(_Inout_ ISource<_Source_type>* _PSource);
ПараметрыParameters
_PSource_PSource
Указатель на ISource
блок, который должен быть связан.A pointer to the ISource
block that is to be linked.
process_input_messagesprocess_input_messages
Обработка входных сообщений.Process input messages. Подходит только для блоков распространения, производных от source_block.This is only useful for propagator blocks, which derive from source_block
virtual void process_input_messages(_Inout_ message<_Target_type>* _PMessage);
ПараметрыParameters
_PMessage_PMessage
Указатель на сообщение, которое должно быть обработано.A pointer to the message that is to be processed.
распространенияpropagate
Асинхронно передает сообщение из исходного блока в этот целевой блок.Asynchronously passes a message from a source block to this target block.
virtual message_status propagate(
_Inout_opt_ message<_Source_type>* _PMessage,
_Inout_opt_ ISource<_Source_type>* _PSource);
ПараметрыParameters
_PMessage_PMessage
Указатель на объект message
.A pointer to the message
object.
_PSource_PSource
Указатель на исходный блок, предлагающий сообщение.A pointer to the source block offering the message.
Возвращаемое значениеReturn Value
Message_status указывает, что цель решила делать с сообщением.A message_status indication of what the target decided to do with the message.
КомментарииRemarks
propagate
Метод вызывается в целевом блоке с помощью связанного исходного блока.The propagate
method is invoked on a target block by a linked source block. Она помещает в очередь асинхронную задачу для работы с сообщением, если она еще не находится в очереди или не исполняется.It queues up an asynchronous task to handle the message, if one is not already queued or executing.
Метод вызывает исключение invalid_argument , если _PMessage
параметр или имеет значение _PSource
NULL
.The method throws an invalid_argument exception if either the _PMessage
or _PSource
parameter is NULL
.
propagate_messagepropagate_message
При переопределении в производном классе этот метод асинхронно передает сообщение из ISource
блока в этот propagator_block
объект.When overridden in a derived class, this method asynchronously passes a message from an ISource
block to this propagator_block
object. Он вызывается propagate
методом при вызове из исходного блока.It is invoked by the propagate
method, when called by a source block.
virtual message_status propagate_message(
_Inout_ message<_Source_type>* _PMessage,
_Inout_ ISource<_Source_type>* _PSource) = 0;
ПараметрыParameters
_PMessage_PMessage
Указатель на объект message
.A pointer to the message
object.
_PSource_PSource
Указатель на исходный блок, предлагающий сообщение.A pointer to the source block offering the message.
Возвращаемое значениеReturn Value
Message_status указывает, что цель решила делать с сообщением.A message_status indication of what the target decided to do with the message.
propagator_blockpropagator_block
Формирует объект propagator_block
.Constructs a propagator_block
object.
propagator_block();
~ propagator_block~propagator_block
Уничтожает объект propagator_block
.Destroys a propagator_block
object.
virtual ~propagator_block();
register_filterregister_filter
Регистрирует метод фильтра, который будет вызываться для каждого полученного сообщения.Registers a filter method that will be invoked on every received message.
void register_filter(filter_method const& _Filter);
ПараметрыParameters
_Filter_Filter
Метод Filter.The filter method.
remove_network_linksremove_network_links
Удаляет все связи исходной и целевой сетей из этого propagator_block
объекта.Removes all the source and target network links from this propagator_block
object.
void remove_network_links();
Отправитьsend
Синхронно инициирует сообщение для этого блока.Synchronously initiates a message to this block. Вызывается ISource
блоком.Called by an ISource
block. По завершении этой функции сообщение уже будет распространено в блок.When this function completes, the message will already have propagated into the block.
virtual message_status send(
_Inout_ message<_Source_type>* _PMessage,
_Inout_ ISource<_Source_type>* _PSource);
ПараметрыParameters
_PMessage_PMessage
Указатель на объект message
.A pointer to the message
object.
_PSource_PSource
Указатель на исходный блок, предлагающий сообщение.A pointer to the source block offering the message.
Возвращаемое значениеReturn Value
Message_status указывает, что цель решила делать с сообщением.A message_status indication of what the target decided to do with the message.
КомментарииRemarks
Этот метод вызывает исключение invalid_argument , если _PMessage
_PSource
параметр или имеет значение NULL
.This method throws an invalid_argument exception if either the _PMessage
or _PSource
parameter is NULL
.
send_messagesend_message
При переопределении в производном классе этот метод синхронно передает сообщение из ISource
блока в этот propagator_block
объект.When overridden in a derived class, this method synchronously passes a message from an ISource
block to this propagator_block
object. Он вызывается send
методом при вызове из исходного блока.It is invoked by the send
method, when called by a source block.
virtual message_status send_message(
_Inout_ message<_Source_type> *,
_Inout_ ISource<_Source_type> *);
Возвращаемое значениеReturn Value
Message_status указывает, что цель решила делать с сообщением.A message_status indication of what the target decided to do with the message.
КомментарииRemarks
По умолчанию этот блок возвращается, declined
если он не переопределен производным классом.By default, this block returns declined
unless overridden by a derived class.
unlink_sourceunlink_source
Отменяет связь указанного исходного блока с этим propagator_block
объектом.Unlinks a specified source block from this propagator_block
object.
virtual void unlink_source(_Inout_ ISource<_Source_type>* _PSource);
ПараметрыParameters
_PSource_PSource
Указатель на ISource
блок, связь с которым необходимо отменить.A pointer to the ISource
block that is to be unlinked.
unlink_sourcesunlink_sources
Отменяет связь со всеми исходными блоками этого propagator_block
объекта.Unlinks all source blocks from this propagator_block
object.
virtual void unlink_sources();
См. также разделSee also
Пространство имен Concurrencyconcurrency Namespace
Класс source_blocksource_block Class
Класс ITargetITarget Class