Task cancellation in VS2010 version
-
Saturday, November 24, 2012 6:44 PM
First I would like to express my thanks to the team for making PPL tasks available for those of us who must stick with VS2010 C++ compiler for a while.
They work great for me so far.
One minor detail: this code below wouldn't compile because interruption_point and is_task_cancellation_requested functions could not be found:
void PrintStuff() { while(true) { //interruption_point(); //if(is_task_cancellation_requested()) //{ // cancel_current_task(); //} std::cout << '.'; } std::cout << std::endl; }I am able to work around these issues by passing cancellation token as a parameter to function. I wonder if I am missing something, or are these functions indeed not implemented, for whatever reason?
In fact, I am not sure that I understand how to create a cancellable task, short of creating an external cancellation token and capturing it in task's lambda.
All Replies
-
Monday, November 26, 2012 8:22 PMOwner
Tonko,
Thanks for the kind words!
The pplx namespace that you see in Casablanca is the beginning of our effort to make PPL platform- and compiler-independent. For now, we ported just enough of the PPL to support asynchronous operations for Casablanca, but not the parts of the PPL that rely on the task_group class, such as the parallel_for and other parallel algorithms.
The APIs you mentioned are useful when combining PPL tasks with the task_group-based parallel algorithms that do not support cancellation tokens.
If you only use PPL tasks and not other PPL algorithms, cancellation tokens is a great way to go. We like them for their explicitness - cancellation tokens make it very clear how the cancellation is requested, how it's propagated to other tasks, and what tasks react to them.
So what you call a work around is actually a perfectly fine way of doing it!
Artur Laksberg Visual C++ Team Microsoft
- Marked As Answer by Tonko Monday, November 26, 2012 10:54 PM

