[fpc-devel] C++ gets language-internal concurrency support

Marco van de Voort marcov at stack.nl
Wed Aug 17 16:24:35 CEST 2011


In our previous episode, Michael Schnell said:
> Some c++11 code doing parallel execution:
> 
> *
>      	void f(vector<double>&);
> 
> 	struct F {
> 		vector<double>&  v;
> 		F(vector<double>&  vv) :v{vv} { }
> 		void operator()();
> 	};
> 
> 	int main()
> 	{
> 		std::thread t1{std::bind(f,some_vec)};	//*f(some_vec) executes in separate thread*
> 		std::thread t2{F(some_vec)};		//*F(some_vec)() executes in separate thread*
> 
> 		t1.join();
> 		t2.join();
> 	}

I'm no C++ expert, but:

Where is the parallel aspect? It looks more like a shorthand to spawn a
thread to evaluate an expression/closure/function call, and then wait on it
using .join().  

The "closure"-like aspect (be able to pass expressions to be evaluated
somewhere else) looks like a bigger feature then that threads are now
grouped under namespace std.

I'm note sure we are actually witnessing something like the parallel for you
talked about earlier?  Are you sure?



More information about the fpc-devel mailing list