when_any 函数 (C++ REST SDK)

创建一个任务,在作为参数提供的任何任务成功完成后,此任务将成功完成。

警告

本主题包含有关 C++ REST SDK 1.0 (codename "Casablanca") 的信息。如果你正在从 Codeplex Casablanca 网页 使用更高版本,则使用 http://casablanca.codeplex.com/documentation 上的本地文档。

template<    typename _Iterator > auto when_any(    _Iterator_Begin,    _Iterator_End,    const task_options& _TaskOptions = task_options() ) -> decltype (details::_WhenAnyImpl<typename std::iterator_traits<_Iterator>::value_type::result_type, _Iterator>::_Perform(_TaskOptions, _Begin, _End));  template<    typename _Iterator > auto when_any(    _Iterator_Begin,    _Iterator_End,    cancellation_token _CancellationToken ) -> decltype (details::_WhenAnyImpl<typename std::iterator_traits<_Iterator>::value_type::result_type, _Iterator>::_Perform(_CancellationToken._GetImplValue(), _Begin, _End));

参数

  • _Iterator
    输入迭代器的类型。

  • _Begin
    要合并到结果任务的元素范围中第一个元素的位置。

  • _End
    超出要合并到结果任务的元素范围的第一个元素的位置。

  • _TaskOptions

  • _CancellationToken
    控制返回的任务的取消的取消标记。 如果未提供取消标记,则结果任务将接收到导致任务完成的任务取消标记。

返回值

在任意输入任务成功完成后成功完成的任务。 如果输入任务的类型为 T,则此函数的输出将为 task<std::pair<T, size_t>>>,其中的 pair 的第一个元素是正在完成的任务的结果,第二个元素是已完成的任务的索引。 如果输入任务的类型为 void,则输出为 task<size_t>,其中的结果是正在完成的任务的索引。

要求

**标头:**pplxtasks.h

**命名空间:**pplx

请参见

参考

pplx 命名空间

概念

任务并行(并发运行时)