Turning on to a parallel approach

Now, we want to add concurrency to the same example. Note that we've designed the CSchwefel class for such a task, because beside the Evaluate method, everything remains the same! Again, the power of object-oriented programming saves us a lot of coding and time.

Getting ready

Make sure that Visual Studio is up and running.

How to do it...

Now, let's create the CSchwefelMT class and explain its structure. Perform the following steps:

  1. Open Solution Explorer and open the file stdafx.h. Copy and paste the following code to it:
    #pragma once
    
    #include "targetver.h"
    
    #include <stdio.h>
    #include <tchar.h>
    #include <Windows.h>
    #include <cfloat>
    #include <time.h>
    #include <omp.h>
    
    #include "Schwefel.h"
    #include "SchwefelMT.h"
  2. Open ...

Get C++ Multithreading Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.