Skip to content

Commit b5cc1a2

Browse files
authored
Merge branch 'master' into cr-workitems
2 parents 1a21999 + 453228a commit b5cc1a2

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

docs/parallel/concrt/cancellation-in-the-ppl.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ This document explains the role of cancellation in the Parallel Patterns Library
5050
- When possible, use cancellation tokens to cancel work. The [concurrency::cancellation_token](../../parallel/concrt/reference/cancellation-token-class.md) class defines a cancellation token.
5151

5252

53-
- When you use cancellation tokens, use the [concurrency::cancellation_token_source::cancel](reference/cancellation-token-source-class.md#cancel) method to initiate cancellation and the [concurrency::cancel_current_task](reference/concurrency-namespace-functions.md#cancel_current_task) function to respond to cancellation.
53+
- When you use cancellation tokens, use the [concurrency::cancellation_token_source::cancel](reference/cancellation-token-source-class.md#cancel) method to initiate cancellation and the [concurrency::cancel_current_task](reference/concurrency-namespace-functions.md#cancel_current_task) function to respond to cancellation. Use the [concurrency::cancellation_token::is_canceled](reference/cancellation-token-class.md#is_canceled) method to check whether any other task has requested cancellation.
5454

5555
- Cancellation does not occur immediately. Although new work is not started if a task or task group is cancelled, active work must check for and respond to cancellation.
5656

@@ -97,7 +97,7 @@ This document explains the role of cancellation in the Parallel Patterns Library
9797
For more examples that cancel parallel tasks, see [Walkthrough: Connecting Using Tasks and XML HTTP Requests](../../parallel/concrt/walkthrough-connecting-using-tasks-and-xml-http-requests.md), [How to: Use Cancellation to Break from a Parallel Loop](../../parallel/concrt/how-to-use-cancellation-to-break-from-a-parallel-loop.md), and [How to: Use Exception Handling to Break from a Parallel Loop](../../parallel/concrt/how-to-use-exception-handling-to-break-from-a-parallel-loop.md).
9898

9999
### <a name="tokens"></a> Using a Cancellation Token to Cancel Parallel Work
100-
The `task`, `task_group`, and `structured_task_group` classes support cancellation through the use of cancellation tokens. The PPL defines the [concurrency::cancellation_token_source](../../parallel/concrt/reference/cancellation-token-source-class.md) and [concurrency::cancellation_token](../../parallel/concrt/reference/cancellation-token-class.md) classes for this purpose. When you use a cancellation token to cancel work, the runtime does not start new work that subscribes to that token. Work that is already active can monitor its cancellation token and stop when it can.
100+
The `task`, `task_group`, and `structured_task_group` classes support cancellation through the use of cancellation tokens. The PPL defines the [concurrency::cancellation_token_source](../../parallel/concrt/reference/cancellation-token-source-class.md) and [concurrency::cancellation_token](../../parallel/concrt/reference/cancellation-token-class.md) classes for this purpose. When you use a cancellation token to cancel work, the runtime does not start new work that subscribes to that token. Work that is already active can use the [is_canceled]((../../parallel/concrt/reference/cancellation-token-class.md#is_canceled) member function to monitor the cancellation token and stop when it can.
101101

102102

103103
To initiate cancellation, call the [concurrency::cancellation_token_source::cancel](reference/cancellation-token-source-class.md#cancel) method. You respond to cancellation in these ways:

docs/parallel/concrt/codesnippet/CPP/cancellation-in-the-ppl_2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ int wmain()
2929
while (moreToDo)
3030
{
3131
// Check for cancellation.
32-
if (is_task_cancellation_requested())
32+
if (token.is_canceled())
3333
{
3434
// TODO: Perform any necessary cleanup here...
3535

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ bool count_primes(unsigned int max_value, unsigned int timeout)
2626
{
2727
// Respond if the overall task is cancelled by canceling
2828
// the current task.
29-
if (is_task_cancellation_requested())
29+
if (cts.get_token().is_canceled())
3030
{
3131
cancel_current_task();
3232
}
33-
// NOTE: You can replace the calls to is_task_cancellation_requested
33+
// NOTE: You can replace the calls to is_canceled
3434
// and cancel_current_task with a call to interruption_point.
3535
// interruption_point();
3636

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ bool count_primes(unsigned int max_value, unsigned int timeout)
9898
{
9999
// Respond if the overall task is cancelled by canceling
100100
// the current task.
101-
if (is_task_cancellation_requested())
101+
if (cts.get_token().is_canceled())
102102
{
103103
cancel_current_task();
104104
}
105-
// NOTE: You can replace the calls to is_task_cancellation_requested
105+
// NOTE: You can replace the calls to is_canceled
106106
// and cancel_current_task with a call to interruption_point.
107107
// interruption_point();
108108

0 commit comments

Comments
 (0)