Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

receive Function

A general receive implementation, allowing a context to wait for data from exactly one source and filter the values that are accepted.

template <
   class _Type
>
_Type receive(
   _Inout_ ISource<_Type> * _Src,
   unsigned int _Timeout = COOPERATIVE_TIMEOUT_INFINITE
);

template <
   class _Type
>
_Type receive(
   _Inout_ 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

The payload type.

_Src

A pointer or reference to the source from which data is expected.

_Timeout

The maximum time for which the method should for the data, in milliseconds.

_Filter_proc

A filter function which determines whether messages should be accepted.

A value from the source, of the payload type.

If the parameter _Timeout has a value other than the constant COOPERATIVE_TIMEOUT_INFINITE, the exception operation_timed_out is thrown if the specified amount of time expires before a message is received. If you want a zero length timeout, you should use the try_receive function, as opposed to calling receive with a timeout of 0 (zero), as it is more efficient and does not throw exceptions on timeouts.

For more information, see Message Passing Functions.

Header: agents.h

Namespace: concurrency

Show:
© 2015 Microsoft