aspose file tools*
The moose likes C / C++ and the fly likes Can C++0X concurrency be implemented only as a library? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » C / C++
Bookmark "Can C++0X concurrency be implemented only as a library?" Watch "Can C++0X concurrency be implemented only as a library?" New topic
Author

Can C++0X concurrency be implemented only as a library?

Orjan Petersson
Greenhorn

Joined: Oct 13, 2003
Posts: 12
Anthony,
I understand I can get a C++0X thread library (like yours :-) to start using the new C++ multithreading features with my current compiler.
However, I suppose there are the other C++0X concurrency features for which I need a new version of the compiler. If so, what are those?

Best regards,
Örjan Petersson
Anthony Aj Williams
author
Ranch Hand

Joined: Jun 10, 2011
Posts: 56
Orjan Petersson wrote:Anthony,
I understand I can get a C++0X thread library (like yours :-) to start using the new C++ multithreading features with my current compiler.
However, I suppose there are the other C++0X concurrency features for which I need a new version of the compiler. If so, what are those?


The key concurrency feature which cannot be implemented as a library is the thread_local keyword. My library provides a macro (JSS_THREAD_LOCAL()) which emulates this facility in some contexts, but it cannot provide a general solution, and requires you to use a macro rather than a keyword.

The use of constexpr to guarantee static initialization for objects of class type (such as std::mutex) cannot be emulated either. In some cases the compiler will naturally do the required static initialization as part of normal optimization, but in others it will generate dynamic initialization code to call the relevant constructor.


Author of C++ Concurrency in Action http://www.stdthread.co.uk/book/
just::thread C++11 thread library http://www.stdthread.co.uk
Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can C++0X concurrency be implemented only as a library?