김용준PPL Study: Composing Tasks
PPL Study: Composing Tasks
김용준
- 실제 문제는 선행 태스크와 후행 태스크가 1:1 대응이 아닌 경우가 많음
- 여러 태스크의 작업 완료 여부에 따라서 n:1 연결을 할 수 있음
- Concurrency::when_all, Concurrency::when_any를 이용해서 해결
태스크 집합의 Join과 Select
PPL Study: Composing Tasks
PPL Study: Composing Tasks
김용준
Concurrency::when_all (ppltask.h)
PPL Study: Composing Tasks
PPL Study: Composing Tasks
template <typename _Iterator>
auto when_all(_Iterator _Begin, _Iterator _End)
-> decltype (details::_WhenAllImpl<typename std::iterator_traits<_Iterator>::value_type::result_type,
_Iterator>::_Perform(nullptr, _Begin, _End))
{
typedef typename std::iterator_traits<_Iterator>::value_type::result_type _ElementType;
return details::_WhenAllImpl<_ElementType, _Iterator>::_Perform(nullptr, _Begin, _End);
}
template <typename _Iterator>
auto when_all(_Iterator _Begin, _Iterator _End, cancellation_token _CancellationToken)
-> decltype (details::_WhenAllImpl<typename std::iterator_traits<_Iterator>::value_type::result_type,
_Iterator>::_Perform(_CancellationToken._GetImplValue(), _Begin, _End))
{
typedef typename std::iterator_traits<_Iterator>::value_type::result_type _ElementType;
return details::_WhenAllImpl<_ElementType, _Iterator>::_Perform(_CancellationToken._GetImplValue(), _Begin, _End);
}
김용준
Concurrency::when_any (ppltask.h)
PPL Study: Composing Tasks
PPL Study: Composing Tasks
template<typename _Iterator>
auto when_any(_Iterator _Begin, _Iterator _End)
-> decltype (details::_WhenAnyImpl<typename std::iterator_traits<_Iterator>::value_type::result_type,
_Iterator>::_Perform(nullptr, _Begin, _End))
{
typedef typename std::iterator_traits<_Iterator>::value_type::result_type _ElementType;
return details::_WhenAnyImpl<_ElementType, _Iterator>::_Perform(nullptr, _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))
{
typedef typename std::iterator_traits<_Iterator>::value_type::result_type _ElementType;
return details::_WhenAnyImpl<_ElementType, _Iterator>::_Perform(_CancellationToken._GetImplValue(), _Begin, _End);
}
여담
when_all과 when_any를 잘보면 template<typename _Iterator>에서 template과 angle bracket(<) 사이에 space가 있을 때도 있고 없을
때도 있네요 ㅋㅋ. 이런 인간적인 실수가 ㅋㅋ.
김용준
PPL Study: Composing Tasks
PPL Study: Composing Tasks
VS2012 provide two overrided functions
template <typename _Iterator>
auto when_all(_Iterator _Begin, _Iterator _End) { ... }
template <typename _Iterator>
auto when_all(_Iterator _Begin, _Iterator _End, cancellation_token _CancellationToken) { ... }
VS2013, 2015 provide this function
auto when_all (_Iterator _Begin, _Iterator _End, const task_options& _TaskOptions = task_options() )
- VS2012의 ppltask.h와 VS2013, 2015가 약간 다름
- task_options은 VS2013에서 새로 추가된 클래스
- task_options has cancellation_token의 형태 (딴것도 많이 갖고 있음)
- 안에 뜯어보면 이거 저거 할말이 많을 것 같던데, 다음주 나오니 궁금해도
참아주세요~
잠깐: VS2012 vs Upper version
김용준
PPL Study: Composing Tasks
PPL Study: Composing Tasks
template <typename _Iterator>
auto when_***(_Iterator _Begin, _Iterator _End) { ... }
template <typename _Iterator>
auto when_***(_Iterator _Begin, _Iterator _End, cancellation_token _CancellationToken) { ... }
_Iterator
The type of the input iterator.
_Begin
The position of the first element in the range of elements to be combined into the resulting task.
_End
The position of the first element beyond the range of elements to be combined into the resulting task.
_CancellationToken
The cancellation token which controls cancellation of the returned task. If you do not provide a cancellation token,
the resulting task will be created with a token that is a combination of all the cancelable tokens (tokens created by
methods other than cancellation_token::none() of the tasks supplied.
반환 된 작업의 취소를 제어 하는 취소 토큰입니다. 취소 토큰을 제공 하지 않으면, 취소될 수 있는 모든 토큰의 조합으로 결과 작업이
만들어 집니다. (토큰 이외의 방법을 사용하여 만든 cancellation_token::none()제공 하는 작업입니다.) – 음 번역이 어렵네요 –ㅁ-
when_all & when_any, Parameters (MSDN VS2012)
김용준
PPL Study: Composing Tasks
PPL Study: Composing Tasks
template <typename _Iterator>
auto when_all(_Iterator _Begin, _Iterator _End) { ... }
template <typename _Iterator>
auto when_all(_Iterator _Begin, _Iterator _End, cancellation_token _CancellationToken) { ... }
Return value
A task that completes sucessfully when all of the input tasks have completed successfully. If the input tasks are of
type T, the output of this function will be a task<std::vector<T>>. If the input tasks are of type void the output task
will also be a task<void>.
모든 입력된 작업이 성공적으로 완료 되면 성공적으로 완료 되는 작업입니다. 입력된 작업 형식이 T인 경우, 이 함수의 출력은
task<std::vector<T>>가 됩니다. 입력된 작업 형식이 void인 경우 출력 작업 또한 task<void>가 됩니다.
Remarks
If one of the tasks is canceled or throws an exception, the returned task will complete early, in the canceled state,
and the exception, if one is encoutered, will be thrown if you call get() or wait() on that task.
작업 중 하나가 작업이 취소 되거나 예외가 throw 됩니다. 반환 된 작업에서 취소 상태를 조기에 완료 및 오류가 발생 한 경우 호출 하는
경우는 예외가 throw 됩니다 경우 get() 또는 wait() 작업을 합니다. – 으억 이거 번역이 왜이럼... 번역을 못하겠습니다. ㅠㅠ
when_all Return value, Remarks (MSDN VS2012)
김용준
PPL Study: Composing Tasks
PPL Study: Composing Tasks
template <typename _Iterator>
auto when_any(_Iterator _Begin, _Iterator _End) { ... }
template <typename _Iterator>
auto when_any(_Iterator _Begin, _Iterator _End, cancellation_token _CancellationToken) { ... }
Return value
A task that completes successfully when any one of the input tasks has completed successfully. If the input tasks are
of type T, the output of this function will be a task<std::pair<T, size_t>>, where the first element of the pair is the
result of the completing task, and the second element is the index of the task that finished. If the input tasks are of
type void the output is a task<size_t>, where the result is the index of the completing task.
입력 작업 중 하나가 성공적으로 완료되는 경우 완료되는 작업입니다. 입력 작업의 형식이 T인 경우 해당 함수의 출력은
task<std::pair<T, size_t>>가 됩니다. pair의 첫 번째 요소는 완료 중인 작업의 결과가 되고 두 번째 요소는 완료된 작업의 인덱스가 됩
니다. 입력 작업이 형식 void인 경우 출력은 task<size_t>로 여기서 결과는 완료 중인 작업의 인덱스입니다.
when_any Return value, Remarks (MSDN VS2012)
김용준
#include <ppltasks.h>
#include <array>
#include <iostream>
#include <numeric>
using namespace Concurrency;
using namespace std;
int wmain()
{
// 세 개의 태스크를 생성하여 병렬로 실행
array<task<int>, 3> tasks =
{
create_task([]() -> int { return 88; }),
create_task([]() -> int { return 42; }),
create_task([]() -> int { return 99; })
};
int sum = 0;
// when_all 함수를 호출하여 세 개의 태스크가
// 모두 완료될 때까지 대기
auto joinTask = when_all(begin(tasks), end(tasks));
When_all Example (in book)
PPL Study: Composing Tasks
PPL Study: Composing Tasks
// 모든 태스크가 완료된 이후에 실행될 태스크 지정
joinTask.then([&sum](vector<int> results)
{
// 세 개의 태스크의 결과 값 합산
sum = accumulate(begin(results), end(results), 0);
}).wait();
// 결과 값 출력
wcout << L"The sum is "<< sum << L"." << endl;
}
auto joinTask = when_all(begin(tasks), end(tasks));
를
auto joinTask = tasks[0] && tasks[1] && tasks[2];
로 변경 가능
김용준
#include <ppltasks.h>
#include <array>
#include <iostream>
using namespace Concurrency;
using namespace std;
int wmain()
{
// 세 개의 태스크를 생성하여 병렬로 실행
array<task<int>, 3> tasks =
{
create_task([]() -> int { return 88; }),
create_task([]() -> int { return 42; }),
create_task([]() -> int { return 99; })
};
// when_any 함수를 호출하여 가장 먼저 완료되는 태스크를 선택
auto selectTask = when_any(begin(tasks), end(tasks));
// 선택된 태스크 완료 이후에 실행될 태스크 지정
selectTask.then([](pair<int, size_t> result)
{
wcout << "First task to finish returns "
<< result.first
<< L" and has index "
<< result.second
<< L'.' << endl;
}).wait();
}
When_any Example (in book)
PPL Study: Composing Tasks
PPL Study: Composing Tasks
auto selectTask = when_any(begin(tasks), end(tasks));
를
auto selectTask = tasks[0] || tasks[1] || tasks[2];
로 변경 가능
김용준
정리
- when_all은 작업 집합이 완료될때 완료되는 작업을 생성
- when_any은 작업 집합의 첫번째 작업이 완료될때 완료되는 작업을 생성
- when_all과 when_any는 각각 &&과 || 연산자로 대체 할 수 있다.
실무 예시 ㅋㅋ
- when_all의 경우 대부분의 상황에 사용될 수 있을듯 (설계, 부재력 등등)
- when_any는 배근 산정에 사용할 수도 있을 것 같은데... 생각해봅시다
Composing Tasks
PPL Study: Composing Tasks
PPL Study: Composing Tasks
김용준
교재
Think About PPL을 이용한 VC++병렬 프로그래밍 (한빛미디어)
MSDN
https://msdn.microsoft.com/ko-kr/library/dd492427.aspx
참고 자료
PPL Study: Composing Tasks
PPL Study: Composing Tasks

More Related Content

PDF
Javascript Closure
PPTX
파이썬 함수 이해하기
PDF
C++ Concurrency in Action 9-2 Interrupting threads
PPTX
Gpg gems1 1.3
PDF
Lambda 란 무엇인가
PDF
[C++]2 variables andselectionstatement
PPTX
골때리는 자바스크립트 발표자료
PDF
스위프트, 코틀린과 모던언어의 특징 (Swift, Kotlin and Modern Languages)
Javascript Closure
파이썬 함수 이해하기
C++ Concurrency in Action 9-2 Interrupting threads
Gpg gems1 1.3
Lambda 란 무엇인가
[C++]2 variables andselectionstatement
골때리는 자바스크립트 발표자료
스위프트, 코틀린과 모던언어의 특징 (Swift, Kotlin and Modern Languages)

What's hot (20)

PDF
[WELC] 22. I Need to Change a Monster Method and I Can’t Write Tests for It
PDF
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 1. primitive
PDF
일단 시작하는 코틀린
PDF
[C++ Korea 2nd Seminar] C++17 Key Features Summary
PDF
자바8 람다식 소개
PDF
java 8 람다식 소개와 의미 고찰
PDF
Ruby Enumerator(루비 열거자) 이해하기
PPTX
프론트엔드스터디 E05 js closure oop
PDF
C++17 Key Features Summary - Ver 2
PDF
2013 C++ Study For Students #1
PPTX
Kotlin with fp
PPTX
포트폴리오에서 사용한 모던 C++
PDF
Effective Modern C++ MVA item 18 Use std::unique_ptr for exclusive-ownership ...
PPTX
파이썬 병렬프로그래밍
PDF
구글테스트
PDF
Javascript 교육자료 pdf
PPTX
[OKKYCON] 박재성 - 의식적인 연습으로 TDD, 리팩토링 연습하기
PPTX
Javascript 실행 가능한 코드(Executable Code)와 실행 콘텍스트(Execution Context), Lexical En...
PDF
6 function
PDF
[C++ Korea 3rd Seminar] 새 C++은 새 Visual Studio에, 좌충우돌 마이그레이션 이야기
[WELC] 22. I Need to Change a Monster Method and I Can’t Write Tests for It
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 1. primitive
일단 시작하는 코틀린
[C++ Korea 2nd Seminar] C++17 Key Features Summary
자바8 람다식 소개
java 8 람다식 소개와 의미 고찰
Ruby Enumerator(루비 열거자) 이해하기
프론트엔드스터디 E05 js closure oop
C++17 Key Features Summary - Ver 2
2013 C++ Study For Students #1
Kotlin with fp
포트폴리오에서 사용한 모던 C++
Effective Modern C++ MVA item 18 Use std::unique_ptr for exclusive-ownership ...
파이썬 병렬프로그래밍
구글테스트
Javascript 교육자료 pdf
[OKKYCON] 박재성 - 의식적인 연습으로 TDD, 리팩토링 연습하기
Javascript 실행 가능한 코드(Executable Code)와 실행 콘텍스트(Execution Context), Lexical En...
6 function
[C++ Korea 3rd Seminar] 새 C++은 새 Visual Studio에, 좌충우돌 마이그레이션 이야기
Ad

Similar to PPL: Composing Tasks (20)

PPTX
Parallel objects
PPTX
Clean code
PDF
14장 - 15장 예외처리, 템플릿
PPTX
Seed2016 - 개미수열 한주영 (annotated)
PPTX
Design Pattern - Multithread Ch10
PDF
06장 함수
PPT
헷갈리는 자바스크립트 정리
PDF
Effective unit testing ch3. 테스트더블
PPTX
국민대학교 고급 시스템 프로젝트 #1
PDF
Modern C++ 프로그래머를 위한 CPP11/14 핵심
PPTX
C++ 프로젝트에 단위 테스트 도입하기
PDF
Multi mechanize
PDF
함수적 사고 2장
DOC
D2 Job Pool
PDF
Spring Boot 2
PPTX
자바스크립트 기초문법~함수기초
PDF
HI-ARC PS 101
PDF
코딩인카페 C&JAVA 기초과정 C프로그래밍(3)
PPT
Multithread programming 20151206_서진택
PDF
Refactoring#9
Parallel objects
Clean code
14장 - 15장 예외처리, 템플릿
Seed2016 - 개미수열 한주영 (annotated)
Design Pattern - Multithread Ch10
06장 함수
헷갈리는 자바스크립트 정리
Effective unit testing ch3. 테스트더블
국민대학교 고급 시스템 프로젝트 #1
Modern C++ 프로그래머를 위한 CPP11/14 핵심
C++ 프로젝트에 단위 테스트 도입하기
Multi mechanize
함수적 사고 2장
D2 Job Pool
Spring Boot 2
자바스크립트 기초문법~함수기초
HI-ARC PS 101
코딩인카페 C&JAVA 기초과정 C프로그래밍(3)
Multithread programming 20151206_서진택
Refactoring#9
Ad

PPL: Composing Tasks

  • 1. 김용준PPL Study: Composing Tasks PPL Study: Composing Tasks
  • 2. 김용준 - 실제 문제는 선행 태스크와 후행 태스크가 1:1 대응이 아닌 경우가 많음 - 여러 태스크의 작업 완료 여부에 따라서 n:1 연결을 할 수 있음 - Concurrency::when_all, Concurrency::when_any를 이용해서 해결 태스크 집합의 Join과 Select PPL Study: Composing Tasks PPL Study: Composing Tasks
  • 3. 김용준 Concurrency::when_all (ppltask.h) PPL Study: Composing Tasks PPL Study: Composing Tasks template <typename _Iterator> auto when_all(_Iterator _Begin, _Iterator _End) -> decltype (details::_WhenAllImpl<typename std::iterator_traits<_Iterator>::value_type::result_type, _Iterator>::_Perform(nullptr, _Begin, _End)) { typedef typename std::iterator_traits<_Iterator>::value_type::result_type _ElementType; return details::_WhenAllImpl<_ElementType, _Iterator>::_Perform(nullptr, _Begin, _End); } template <typename _Iterator> auto when_all(_Iterator _Begin, _Iterator _End, cancellation_token _CancellationToken) -> decltype (details::_WhenAllImpl<typename std::iterator_traits<_Iterator>::value_type::result_type, _Iterator>::_Perform(_CancellationToken._GetImplValue(), _Begin, _End)) { typedef typename std::iterator_traits<_Iterator>::value_type::result_type _ElementType; return details::_WhenAllImpl<_ElementType, _Iterator>::_Perform(_CancellationToken._GetImplValue(), _Begin, _End); }
  • 4. 김용준 Concurrency::when_any (ppltask.h) PPL Study: Composing Tasks PPL Study: Composing Tasks template<typename _Iterator> auto when_any(_Iterator _Begin, _Iterator _End) -> decltype (details::_WhenAnyImpl<typename std::iterator_traits<_Iterator>::value_type::result_type, _Iterator>::_Perform(nullptr, _Begin, _End)) { typedef typename std::iterator_traits<_Iterator>::value_type::result_type _ElementType; return details::_WhenAnyImpl<_ElementType, _Iterator>::_Perform(nullptr, _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)) { typedef typename std::iterator_traits<_Iterator>::value_type::result_type _ElementType; return details::_WhenAnyImpl<_ElementType, _Iterator>::_Perform(_CancellationToken._GetImplValue(), _Begin, _End); } 여담 when_all과 when_any를 잘보면 template<typename _Iterator>에서 template과 angle bracket(<) 사이에 space가 있을 때도 있고 없을 때도 있네요 ㅋㅋ. 이런 인간적인 실수가 ㅋㅋ.
  • 5. 김용준 PPL Study: Composing Tasks PPL Study: Composing Tasks VS2012 provide two overrided functions template <typename _Iterator> auto when_all(_Iterator _Begin, _Iterator _End) { ... } template <typename _Iterator> auto when_all(_Iterator _Begin, _Iterator _End, cancellation_token _CancellationToken) { ... } VS2013, 2015 provide this function auto when_all (_Iterator _Begin, _Iterator _End, const task_options& _TaskOptions = task_options() ) - VS2012의 ppltask.h와 VS2013, 2015가 약간 다름 - task_options은 VS2013에서 새로 추가된 클래스 - task_options has cancellation_token의 형태 (딴것도 많이 갖고 있음) - 안에 뜯어보면 이거 저거 할말이 많을 것 같던데, 다음주 나오니 궁금해도 참아주세요~ 잠깐: VS2012 vs Upper version
  • 6. 김용준 PPL Study: Composing Tasks PPL Study: Composing Tasks template <typename _Iterator> auto when_***(_Iterator _Begin, _Iterator _End) { ... } template <typename _Iterator> auto when_***(_Iterator _Begin, _Iterator _End, cancellation_token _CancellationToken) { ... } _Iterator The type of the input iterator. _Begin The position of the first element in the range of elements to be combined into the resulting task. _End The position of the first element beyond the range of elements to be combined into the resulting task. _CancellationToken The cancellation token which controls cancellation of the returned task. If you do not provide a cancellation token, the resulting task will be created with a token that is a combination of all the cancelable tokens (tokens created by methods other than cancellation_token::none() of the tasks supplied. 반환 된 작업의 취소를 제어 하는 취소 토큰입니다. 취소 토큰을 제공 하지 않으면, 취소될 수 있는 모든 토큰의 조합으로 결과 작업이 만들어 집니다. (토큰 이외의 방법을 사용하여 만든 cancellation_token::none()제공 하는 작업입니다.) – 음 번역이 어렵네요 –ㅁ- when_all & when_any, Parameters (MSDN VS2012)
  • 7. 김용준 PPL Study: Composing Tasks PPL Study: Composing Tasks template <typename _Iterator> auto when_all(_Iterator _Begin, _Iterator _End) { ... } template <typename _Iterator> auto when_all(_Iterator _Begin, _Iterator _End, cancellation_token _CancellationToken) { ... } Return value A task that completes sucessfully when all of the input tasks have completed successfully. If the input tasks are of type T, the output of this function will be a task<std::vector<T>>. If the input tasks are of type void the output task will also be a task<void>. 모든 입력된 작업이 성공적으로 완료 되면 성공적으로 완료 되는 작업입니다. 입력된 작업 형식이 T인 경우, 이 함수의 출력은 task<std::vector<T>>가 됩니다. 입력된 작업 형식이 void인 경우 출력 작업 또한 task<void>가 됩니다. Remarks If one of the tasks is canceled or throws an exception, the returned task will complete early, in the canceled state, and the exception, if one is encoutered, will be thrown if you call get() or wait() on that task. 작업 중 하나가 작업이 취소 되거나 예외가 throw 됩니다. 반환 된 작업에서 취소 상태를 조기에 완료 및 오류가 발생 한 경우 호출 하는 경우는 예외가 throw 됩니다 경우 get() 또는 wait() 작업을 합니다. – 으억 이거 번역이 왜이럼... 번역을 못하겠습니다. ㅠㅠ when_all Return value, Remarks (MSDN VS2012)
  • 8. 김용준 PPL Study: Composing Tasks PPL Study: Composing Tasks template <typename _Iterator> auto when_any(_Iterator _Begin, _Iterator _End) { ... } template <typename _Iterator> auto when_any(_Iterator _Begin, _Iterator _End, cancellation_token _CancellationToken) { ... } Return value A task that completes successfully when any one of the input tasks has completed successfully. If the input tasks are of type T, the output of this function will be a task<std::pair<T, size_t>>, where the first element of the pair is the result of the completing task, and the second element is the index of the task that finished. If the input tasks are of type void the output is a task<size_t>, where the result is the index of the completing task. 입력 작업 중 하나가 성공적으로 완료되는 경우 완료되는 작업입니다. 입력 작업의 형식이 T인 경우 해당 함수의 출력은 task<std::pair<T, size_t>>가 됩니다. pair의 첫 번째 요소는 완료 중인 작업의 결과가 되고 두 번째 요소는 완료된 작업의 인덱스가 됩 니다. 입력 작업이 형식 void인 경우 출력은 task<size_t>로 여기서 결과는 완료 중인 작업의 인덱스입니다. when_any Return value, Remarks (MSDN VS2012)
  • 9. 김용준 #include <ppltasks.h> #include <array> #include <iostream> #include <numeric> using namespace Concurrency; using namespace std; int wmain() { // 세 개의 태스크를 생성하여 병렬로 실행 array<task<int>, 3> tasks = { create_task([]() -> int { return 88; }), create_task([]() -> int { return 42; }), create_task([]() -> int { return 99; }) }; int sum = 0; // when_all 함수를 호출하여 세 개의 태스크가 // 모두 완료될 때까지 대기 auto joinTask = when_all(begin(tasks), end(tasks)); When_all Example (in book) PPL Study: Composing Tasks PPL Study: Composing Tasks // 모든 태스크가 완료된 이후에 실행될 태스크 지정 joinTask.then([&sum](vector<int> results) { // 세 개의 태스크의 결과 값 합산 sum = accumulate(begin(results), end(results), 0); }).wait(); // 결과 값 출력 wcout << L"The sum is "<< sum << L"." << endl; } auto joinTask = when_all(begin(tasks), end(tasks)); 를 auto joinTask = tasks[0] && tasks[1] && tasks[2]; 로 변경 가능
  • 10. 김용준 #include <ppltasks.h> #include <array> #include <iostream> using namespace Concurrency; using namespace std; int wmain() { // 세 개의 태스크를 생성하여 병렬로 실행 array<task<int>, 3> tasks = { create_task([]() -> int { return 88; }), create_task([]() -> int { return 42; }), create_task([]() -> int { return 99; }) }; // when_any 함수를 호출하여 가장 먼저 완료되는 태스크를 선택 auto selectTask = when_any(begin(tasks), end(tasks)); // 선택된 태스크 완료 이후에 실행될 태스크 지정 selectTask.then([](pair<int, size_t> result) { wcout << "First task to finish returns " << result.first << L" and has index " << result.second << L'.' << endl; }).wait(); } When_any Example (in book) PPL Study: Composing Tasks PPL Study: Composing Tasks auto selectTask = when_any(begin(tasks), end(tasks)); 를 auto selectTask = tasks[0] || tasks[1] || tasks[2]; 로 변경 가능
  • 11. 김용준 정리 - when_all은 작업 집합이 완료될때 완료되는 작업을 생성 - when_any은 작업 집합의 첫번째 작업이 완료될때 완료되는 작업을 생성 - when_all과 when_any는 각각 &&과 || 연산자로 대체 할 수 있다. 실무 예시 ㅋㅋ - when_all의 경우 대부분의 상황에 사용될 수 있을듯 (설계, 부재력 등등) - when_any는 배근 산정에 사용할 수도 있을 것 같은데... 생각해봅시다 Composing Tasks PPL Study: Composing Tasks PPL Study: Composing Tasks
  • 12. 김용준 교재 Think About PPL을 이용한 VC++병렬 프로그래밍 (한빛미디어) MSDN https://msdn.microsoft.com/ko-kr/library/dd492427.aspx 참고 자료 PPL Study: Composing Tasks PPL Study: Composing Tasks