共用方式為


receive 函式

一般接收實作,可讓內容等候來自一個來源的資料,並且篩選所接受的值。

template <
   class _Type
>
_Type receive(
   ISource<_Type> * _Src,
   unsigned int _Timeout = COOPERATIVE_TIMEOUT_INFINITE
);
template <
   class _Type
>
_Type receive(
   ISource<_Type> * _Src,
   typename ITarget<_Type>::filter_method const& _Filter_proc,
   unsigned int _Timeout = COOPERATIVE_TIMEOUT_INFINITE
);
template <
   class _Type
>
_Type receive(
   ISource<_Type> &_Src,
   unsigned int _Timeout = COOPERATIVE_TIMEOUT_INFINITE
);
template <
   class _Type
>
_Type receive(
   ISource<_Type> &_Src,
   typename ITarget<_Type>::filter_method const& _Filter_proc,
   unsigned int _Timeout = COOPERATIVE_TIMEOUT_INFINITE
);

參數

  • _Type
    承載類型。

  • _Src
    預期資料來源的指標或參考。

  • _Timeout
    方法應用於資料的最大時間 (以毫秒為單位)。

  • _Filter_proc
    篩選條件函式,決定是否應該接受訊息。

傳回值

來自承載類型之來源的值。

備註

如果參數 _Timeout 擁有常數 COOPERATIVE_TIMEOUT_INFINITE以外的其他值,若指定的時間在接收到訊息之前逾期,則會擲回例外狀況 operation_timed_out。 如果您要設定零長度逾時,應使用 try_receive 函式,而不是呼叫 receive 搭配逾時 0 (零),因為這樣比較有效率,而且不會擲回關於逾時的例外狀況。

如需詳細資訊,請參閱訊息傳遞函式

需求

標頭: agents.h

**命名空間:**並行

請參閱

參考

Concurrency 命名空間

try_receive 函式

send 函式

asend 函式