Класс unbounded_bufferunbounded_buffer Class
Блок обмена сообщениями unbounded_buffer
— это упорядоченный блок propagator_block
с несколькими целями и несколькими источниками, который может хранить неограниченное число сообщений.An unbounded_buffer
messaging block is a multi-target, multi-source, ordered propagator_block
capable of storing an unbounded number of messages.
СинтаксисSyntax
template<
class _Type
>
class unbounded_buffer : public propagator_block<multi_link_registry<ITarget< _Type>>, multi_link_registry<ISource< _Type>>>;
ПараметрыParameters
_Type_Type
Тип полезных данных сообщений, хранимых и распространяемых буфером.The payload type of the messages stored and propagated by the buffer.
ЭлементыMembers
Открытые конструкторыPublic Constructors
nameName | ОписаниеDescription |
---|---|
unbounded_bufferunbounded_buffer | Перегружен.Overloaded. Конструирует unbounded_buffer блок обмена сообщениями.Constructs an unbounded_buffer messaging block. |
Деструктор ~ unbounded_buffer~unbounded_buffer Destructor | Уничтожает unbounded_buffer блок обмена сообщениями.Destroys the unbounded_buffer messaging block. |
Открытые методыPublic Methods
nameName | ОписаниеDescription |
---|---|
вывести из очередиdequeue | Удаляет элемент из unbounded_buffer блока обмена сообщениями.Removes an item from the unbounded_buffer messaging block. |
поставить в очередьenqueue | Добавляет элемент в unbounded_buffer блок обмена сообщениями.Adds an item to the unbounded_buffer messaging block. |
Защищенные методыProtected Methods
ИмяName | ОписаниеDescription |
---|---|
accept_messageaccept_message | Принимает сообщение, которое было предложено этим unbounded_buffer блоком обмена сообщениями, передавая владение вызывающему объекту.Accepts a message that was offered by this unbounded_buffer messaging block, transferring ownership to the caller. |
consume_messageconsume_message | Использует сообщение, которое было ранее предложено unbounded_buffer блоком обмена сообщениями и зарезервировано целевым объектом, передавая владение вызывающему объекту.Consumes a message previously offered by the unbounded_buffer messaging block and reserved by the target, transferring ownership to the caller. |
link_target_notificationlink_target_notification | Обратный вызов, уведомляющий о том, что новый целевой объект связан с этим unbounded_buffer блоком обмена сообщениями.A callback that notifies that a new target has been linked to this unbounded_buffer messaging block. |
process_input_messagesprocess_input_messages | Помещает объект message _PMessage в этот unbounded_buffer блок обмена сообщениями и пытается предложить его всем связанным целевым объектам.Places the message _PMessage in this unbounded_buffer messaging block and tries to offer it to all of the linked targets. |
propagate_messagepropagate_message | Асинхронно передает сообщение из ISource блока в этот unbounded_buffer блок обмена сообщениями.Asynchronously passes a message from an ISource block to this unbounded_buffer messaging block. Он вызывается propagate методом при вызове из исходного блока.It is invoked by the propagate method, when called by a source block. |
propagate_output_messagespropagate_output_messages | Помещает объект message _PMessage в этот unbounded_buffer блок обмена сообщениями и пытается предложить его всем связанным целевым объектам.Places the message _PMessage in this unbounded_buffer messaging block and tries to offer it to all of the linked targets. (Переопределяет source_block::p ropagate_output_messages.)(Overrides source_block::propagate_output_messages.) |
release_messagerelease_message | Освобождает предыдущее резервирование сообщения.Releases a previous message reservation. (Переопределяет source_block:: release_message.)(Overrides source_block::release_message.) |
reserve_messagereserve_message | Резервирует сообщение, которое было ранее предложено этим unbounded_buffer блоком обмена сообщениями.Reserves a message previously offered by this unbounded_buffer messaging block. (Переопределяет source_block:: reserve_message.)(Overrides source_block::reserve_message.) |
resume_propagationresume_propagation | Возобновляет распространение после освобождения резервирования.Resumes propagation after a reservation has been released. (Переопределяет source_block:: resume_propagation.)(Overrides source_block::resume_propagation.) |
send_messagesend_message | Синхронно передает сообщение из ISource блока в этот unbounded_buffer блок обмена сообщениями.Synchronously passes a message from an ISource block to this unbounded_buffer messaging block. Он вызывается send методом при вызове из исходного блока.It is invoked by the send method, when called by a source block. |
supports_anonymous_sourcesupports_anonymous_source | Переопределяет метод supports_anonymous_source , чтобы указать, что данный блок может принимать сообщения, предоставляемые ему несвязанным источником.Overrides the supports_anonymous_source method to indicate that this block can accept messages offered to it by a source that is not linked. (Переопределяет метод ITarget:: supports_anonymous_source.)(Overrides ITarget::supports_anonymous_source.) |
Дополнительные сведения см. в разделе асинхронные блоки сообщений.For more information, see Asynchronous Message Blocks.
Иерархия наследованияInheritance Hierarchy
propagator_blockpropagator_block
unbounded_buffer
ТребованияRequirements
Заголовок: agents.hHeader: agents.h
Пространство имен: параллелизмNamespace: concurrency
accept_messageaccept_message
Принимает сообщение, которое было предложено этим unbounded_buffer
блоком обмена сообщениями, передавая владение вызывающему объекту.Accepts a message that was offered by this unbounded_buffer
messaging block, transferring ownership to the caller.
virtual message<_Type> * accept_message(
runtime_object_identity _MsgId
);
ПараметрыParameters
_MsgId_MsgId
runtime_object_identity
Объект предлагаемого message
объекта.The runtime_object_identity
of the offered message
object.
Возвращаемое значениеReturn Value
Указатель на message
объект, владельцем которого стал вызывающий объект.A pointer to the message
object that the caller now has ownership of.
consume_messageconsume_message
Использует сообщение, которое было ранее предложено unbounded_buffer
блоком обмена сообщениями и зарезервировано целевым объектом, передавая владение вызывающему объекту.Consumes a message previously offered by the unbounded_buffer
messaging block and reserved by the target, transferring ownership to the caller.
virtual message<_Type> * consume_message(
runtime_object_identity _MsgId
);
ПараметрыParameters
_MsgId_MsgId
runtime_object_identity
Объект для используемого message
объекта.The runtime_object_identity
of the message
object being consumed.
Возвращаемое значениеReturn Value
Указатель на message
объект, владельцем которого стал вызывающий объект.A pointer to the message
object that the caller now has ownership of.
КомментарииRemarks
Аналогично accept
, но всегда предшествует вызову reserve
.Similar to accept
, but is always preceded by a call to reserve
.
вывода из очередиdequeue
Удаляет элемент из unbounded_buffer
блока обмена сообщениями.Removes an item from the unbounded_buffer
messaging block.
_Type dequeue();
Возвращаемое значениеReturn Value
Полезные данные сообщения, удаленные из unbounded_buffer
.The payload of the message removed from the unbounded_buffer
.
очередьenqueue
Добавляет элемент в unbounded_buffer
блок обмена сообщениями.Adds an item to the unbounded_buffer
messaging block.
bool enqueue(
_Type const& _Item
);
ПараметрыParameters
_Item_Item
Добавляемый элемент.The item to add.
Возвращаемое значениеReturn Value
true
значение, если элемент был принят, false
в противном случае.true
if the item was accepted, false
otherwise.
link_target_notificationlink_target_notification
Обратный вызов, уведомляющий о том, что новый целевой объект связан с этим unbounded_buffer
блоком обмена сообщениями.A callback that notifies that a new target has been linked to this unbounded_buffer
messaging block.
virtual void link_target_notification(
_Inout_ ITarget<_Type> * _PTarget
);
ПараметрыParameters
_PTarget_PTarget
Указатель на вновь связанный целевой объект.A pointer to the newly linked target.
propagate_messagepropagate_message
Асинхронно передает сообщение из ISource
блока в этот unbounded_buffer
блок обмена сообщениями.Asynchronously passes a message from an ISource
block to this unbounded_buffer
messaging block. Он вызывается propagate
методом при вызове из исходного блока.It is invoked by the propagate
method, when called by a source block.
virtual message_status propagate_message(
_Inout_ message<_Type> * _PMessage,
_Inout_ ISource<_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.
propagate_output_messagespropagate_output_messages
Помещает объект message
_PMessage
в этот unbounded_buffer
блок обмена сообщениями и пытается предложить его всем связанным целевым объектам.Places the message
_PMessage
in this unbounded_buffer
messaging block and tries to offer it to all of the linked targets.
virtual void propagate_output_messages();
КомментарииRemarks
Если другое сообщение уже находится впереди этого в unbounded_buffer
, распространение на связанные целевые объекты не будет выполняться, пока не будут приняты или использованы все предыдущие сообщения.If another message is already ahead of this one in the unbounded_buffer
, propagation to linked targets will not occur until any earlier messages have been accepted or consumed. Первая связанная цель для успешного завершения accept
или consume
сообщение становится владельцем, и никакая другая цель не может получить сообщение.The first linked target to successfully accept
or consume
the message takes ownership, and no other target can then get the message.
process_input_messagesprocess_input_messages
Помещает объект message
_PMessage
в этот unbounded_buffer
блок обмена сообщениями и пытается предложить его всем связанным целевым объектам.Places the message
_PMessage
in this unbounded_buffer
messaging block and tries to offer it to all of the linked targets.
virtual void process_input_messages(
_Inout_ message<_Type> * _PMessage
);
ПараметрыParameters
_PMessage_PMessage
Указатель на сообщение, которое должно быть обработано.A pointer to the message that is to be processed.
release_messagerelease_message
Освобождает предыдущее резервирование сообщения.Releases a previous message reservation.
virtual void release_message(
runtime_object_identity _MsgId
);
ПараметрыParameters
_MsgId_MsgId
runtime_object_identity
message
Объект для освобожденного объекта.The runtime_object_identity
of the message
object being released.
reserve_messagereserve_message
Резервирует сообщение, которое было ранее предложено этим unbounded_buffer
блоком обмена сообщениями.Reserves a message previously offered by this unbounded_buffer
messaging block.
virtual bool reserve_message(
runtime_object_identity _MsgId
);
ПараметрыParameters
_MsgId_MsgId
runtime_object_identity
message
Объект для резервируемого объекта.The runtime_object_identity
of the message
object being reserved.
Возвращаемое значениеReturn Value
true
значение, если сообщение было успешно зарезервировано, false
в противном случае.true
if the message was successfully reserved, false
otherwise.
КомментарииRemarks
После reserve
вызова метода, если он возвращает значение true
, consume
release
метод или должен быть вызван, чтобы принять или освободить владение сообщением.After reserve
is called, if it returns true
, either consume
or release
must be called to either take or release ownership of the message.
resume_propagationresume_propagation
Возобновляет распространение после освобождения резервирования.Resumes propagation after a reservation has been released.
virtual void resume_propagation();
send_messagesend_message
Синхронно передает сообщение из ISource
блока в этот unbounded_buffer
блок обмена сообщениями.Synchronously passes a message from an ISource
block to this unbounded_buffer
messaging block. Он вызывается send
методом при вызове из исходного блока.It is invoked by the send
method, when called by a source block.
virtual message_status send_message(
_Inout_ message<_Type> * _PMessage,
_Inout_ ISource<_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.
supports_anonymous_sourcesupports_anonymous_source
Переопределяет метод supports_anonymous_source
, чтобы указать, что данный блок может принимать сообщения, предоставляемые ему несвязанным источником.Overrides the supports_anonymous_source
method to indicate that this block can accept messages offered to it by a source that is not linked.
virtual bool supports_anonymous_source();
Возвращаемое значениеReturn Value
true
так как блок не откладывает предлагаемые сообщения.true
because the block does not postpone offered messages.
unbounded_bufferunbounded_buffer
Конструирует unbounded_buffer
блок обмена сообщениями.Constructs an unbounded_buffer
messaging block.
unbounded_buffer();
unbounded_buffer(
filter_method const& _Filter
);
unbounded_buffer(
Scheduler& _PScheduler
);
unbounded_buffer(
Scheduler& _PScheduler,
filter_method const& _Filter
);
unbounded_buffer(
ScheduleGroup& _PScheduleGroup
);
unbounded_buffer(
ScheduleGroup& _PScheduleGroup,
filter_method const& _Filter
);
ПараметрыParameters
_Filter_Filter
Функция фильтра, которая определяет, следует ли принимать предлагаемые сообщения.A filter function which determines whether offered messages should be accepted.
_PScheduler_PScheduler
Объект Scheduler
, в котором запланирована задача распространения для блока обмена сообщениями unbounded_buffer
.The Scheduler
object within which the propagation task for the unbounded_buffer
messaging block is scheduled.
_PScheduleGroup_PScheduleGroup
Объект ScheduleGroup
, в котором запланирована задача распространения для блока обмена сообщениями unbounded_buffer
.The ScheduleGroup
object within which the propagation task for the unbounded_buffer
messaging block is scheduled. Используемый объект Scheduler
подразумевается группой расписаний.The Scheduler
object used is implied by the schedule group.
КомментарииRemarks
Среда выполнения использует планировщик по умолчанию, если вы не указали параметры _PScheduler
или _PScheduleGroup
.The runtime uses the default scheduler if you do not specify the _PScheduler
or _PScheduleGroup
parameters.
Тип filter_method
— это функтор с сигнатурой, bool (_Type const &)
которая вызывается этим unbounded_buffer
блоком обмена сообщениями для определения того, следует ли принимать предложенное сообщение.The type filter_method
is a functor with signature bool (_Type const &)
which is invoked by this unbounded_buffer
messaging block to determine whether or not it should accept an offered message.
~ unbounded_buffer~unbounded_buffer
Уничтожает unbounded_buffer
блок обмена сообщениями.Destroys the unbounded_buffer
messaging block.
~unbounded_buffer();
См. также разделSee also
Пространство имен Concurrencyconcurrency Namespace
Класс overwrite_bufferoverwrite_buffer Class
Класс single_assignmentsingle_assignment Class