Skip to content

Commit 739715e

Browse files
author
Colin Robertson
committed
Move out code change
1 parent d9bc04f commit 739715e

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

docs/parallel/concrt/codesnippet/CPP/how-to-create-a-task-that-completes-after-a-delay_2.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ bool count_primes(unsigned int max_value, unsigned int timeout)
1919

2020
// Create a task that computes the count of prime numbers.
2121
// The task is canceled after the specified timeout.
22-
auto t = cancel_after_timeout(task<size_t>([max_value, timeout, cts]
22+
auto t = cancel_after_timeout(task<size_t>([max_value, timeout]
2323
{
2424
combinable<size_t> counts;
25-
parallel_for<unsigned int>(0, max_value + 1, [&counts, cts](unsigned int n)
25+
parallel_for<unsigned int>(0, max_value + 1, [&counts](unsigned int n)
2626
{
2727
// Respond if the overall task is cancelled by canceling
2828
// the current task.
@@ -52,7 +52,7 @@ bool count_primes(unsigned int max_value, unsigned int timeout)
5252
<< timeout << L" ms." << endl;
5353
return true;
5454
}
55-
catch (const task_canceled&)
55+
catch (const task_canceled& e)
5656
{
5757
wcout << L"The task timed out." << endl;
5858
return false;

docs/parallel/concrt/codesnippet/CPP/how-to-create-a-task-that-completes-after-a-delay_3.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// task-delay.cpp
22
// compile with: /EHsc
3-
#include <ppl.h>
43
#include <ppltasks.h>
54
#include <agents.h>
65
#include <iostream>
@@ -92,10 +91,10 @@ bool count_primes(unsigned int max_value, unsigned int timeout)
9291

9392
// Create a task that computes the count of prime numbers.
9493
// The task is canceled after the specified timeout.
95-
auto t = cancel_after_timeout(task<size_t>([max_value, timeout, cts]
94+
auto t = cancel_after_timeout(task<size_t>([max_value, timeout]
9695
{
9796
combinable<size_t> counts;
98-
parallel_for<unsigned int>(0, max_value + 1, [&counts, cts](unsigned int n)
97+
parallel_for<unsigned int>(0, max_value + 1, [&counts](unsigned int n)
9998
{
10099
// Respond if the overall task is cancelled by canceling
101100
// the current task.
@@ -125,7 +124,7 @@ bool count_primes(unsigned int max_value, unsigned int timeout)
125124
<< timeout << L" ms." << endl;
126125
return true;
127126
}
128-
catch (const task_canceled&)
127+
catch (const task_canceled& e)
129128
{
130129
wcout << L"The task timed out." << endl;
131130
return false;

0 commit comments

Comments
 (0)