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

David W Noon david.w.noon at ntlworld.com
Wed Aug 17 18:03:27 CEST 2011


On Wed, 17 Aug 2011 16:24:35 +0200 (CEST), Marco van de Voort wrote
about Re: [fpc-devel] C++ gets language-internal concurrency support:

> In our previous episode, Michael Schnell said:
[snip]
>> 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:

I am (reasonably so, at least).

> Where is the parallel aspect?

The threads t1 and t2 execute in parallel.  Moreover, they will execute
in parallel with any code that occurs between the declaration that
start the threads and the join() method calls that synchronize them
with the invoking thread.  On a SMP system they will execute physically
in parallel, not simply timesliced against one another.  The underlying
implementation model is that of POSIX threads.

This is tantamount to the TThread class (e.g. from Borland C++) becoming
part of the C++ Standard Template Library (STL).  It is nothing
particularly new or special, but at least the C++ standard now
acknowledges concurrent execution and its need for reentrancy.
-- 
Regards,

Dave  [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
david.w.noon at ntlworld.com (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20110817/4bf0372d/attachment.sig>


More information about the fpc-devel mailing list