try_receive 函数

一般尝试接收实现,允许上下文仅查找<来自一个源的数据并筛选所接受的值。 如果数据未就绪,则该方法将返回 false。

template <
   class _Type
>
bool try_receive(
   ISource<_Type> * _Src,
   _Type & _value
);
template <
   class _Type
>
bool try_receive(
   ISource<_Type> * _Src,
   _Type & _value,
   typename ITarget<_Type>::filter_method const& _Filter_proc
);
template <
   class _Type
>
bool try_receive(
   ISource<_Type> & _Src,
   _Type & _value
);
template <
   class _Type
>
bool try_receive(
   ISource<_Type> & _Src,
   _Type & _value,
   typename ITarget<_Type>::filter_method const& _Filter_proc
);

参数

  • _Type
    负载类型。

  • _Src
    指向期望数据的源的指针或对期望数据的源的引用。

  • _value
    对将放置结果的位置的引用。

  • _Filter_proc
    确定是否应该接受消息的筛选器函数。

返回值

一个 bool 值,指示是否将负载置于 _value 中。

备注

有关更多信息,请参见 消息传递函数

要求

**标头:**agents.h

命名空间: 并发

请参见

参考

Concurrency 命名空间

receive 函数

send 函数

asend 函数