August 16th, 2010
Disclaimer: This is my first book review and I am definitely not a book critic. I don’t know which criteria should a good book satisfy or what makes a book better than another, at least from a formal point of view. All what I can tell you is how useful it was for me.
The book is divided by into 8 chapters:
The first chapter is, what a surprise, the introduction. It answers such questions like why should you care about concurrency and parallel programming.
The second chapter introduces the Task class of the Task Parallel Library (TPL) and handles almost all aspects of using it; like staring , cancellation, coordination and handling exceptions of tasks. This chapter makes you love tasks and wish you have never worked with threads.
The third and fourth chapters are about sharing data and coordinating tasks in more details. Those two chapters are what make this book a book about real world problems. You see in this chapter how solve real problems with shared data and control flow. You don’t do solve just embarrassingly parallel problems. Free lunch is over! The subjects in those chapters include locking primitives, signaling other tasks /thread to do work. All of that in great details.
The second two chapters are about parallel loops and parallel Linq. It handles the specialties of those aspects like breaking from a parallel loop or managing order while using parallel Linq.
The seventh chapter is about testing and debugging. It shows the new capabilities in Visual Studio 2010, its strengths and weaknesses and how to make use of them.
The last chapter is a great prologue. It shows how to use the TPL to implement well known algorithms like quick sort and MapReduce.
After this small summary of the book I will show the things I liked and things I didn’t.
Lets start with the positive side of this parallel coin.
- All mentioned aspects are handled in great details. If its tasks coordination, you will know how to wait for tasks, how to start a new task after another task finished successfully or with an exception and how to cancel scheduled tasks. Synchronization Primitives are handled in all details. How to use them, when to use the slim version of them, etc.
- At the end of each chapter there is a section about common problems and their causes. You learn which conditions produce such pitfalls and how to avoid them. Actually I have never heard about some of them. I found this chapter to be invaluable.
- The practical last chapter helps you solving the jigsaw and orchestrating the small parts of the previous chapters to build real world solutions.
- I’m not sure if this behavior is intended, but this book is merely about the TPL. All introduces techniques, with exception of the Synchronization Primitives maybe, are from the TPL. Threads are mentioned only sparely as way to manage tasks scheduling. Did threads become useless (at least to work directly with)? Are ThreadPools obsolete? I don’t know. I wish the book mentioned that explicitly.
- The Monitor class has only been mentioned in conjuction with locking objects, but you could use it for other things, like wait and pulsing. I’m not sure if you could simulate this behavior with [(a Manual)|(an Auto)]-ResetEvent. But this should have been mentioned.
- The book has its own convention in naming namespaces, classes and private methods. The namespace Speculative_Cache and class name Use_Speculative_Cache do not conform to the established conventions. Starting private methods with small letter is also not very common in the .Net world.
A great book about the TPL. If you are a .NET programmer then you should read it. If you think you don’t have to because you will not be needing parallel programming in your daily job then you are the most suitable audience for this book. Your programs will perform better if you learned how make independent small chunks run independently.