12/23/2013

TBB example source code ( parallel_invoke function )

You need TBB lib to run this source code.

Download TBB file, and unzip your propely new folder in your computer.
And copy dll files into windows\system folder.

TBB download url -> https://www.threadingbuildingblocks.org/download

 
 
Set path of TBB incoude, lib location on the Visual studio.
 



This is example source code.
 

/////
#include < stdio.h>
#include < tchar.h>
#include < time.h>
#include < tbb/tbb.h>

#ifdef _DEBUG
#pragma comment(lib, "tbb_debug.lib")
#else
#pragma comment(lib, "tbb.lib");
#endif // _DEBUG

using namespace tbb;

void main()
{
 task_scheduler_init init;

 parallel_invoke(
  []()->void
 {
  ::Sleep(1000);
  ::printf("finish:%d\n", 1000);
 },
  []()->void
 {
  ::Sleep(1000);
  ::printf("finish:%d\n", 10000);
 });

 printf("All work is done \n");

 getchar();
 
}
/////

No comments:

Post a Comment