4

i wants to implement a cross platform multithreading program and read that std does support multithreading throug std::thread class but i am not sure if MSVC 11 does support it on this page http://blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.aspx

it says about Concurreny Memory Model

Memory model: N2429 made the Core Language recognize the existence of multithreading, but there appears to be nothing for a compiler implementation to do (at least, one that already supported multithreading). So it's N/A in the table

but in the same time the thread header is indeed included in Visual studio 2012

so can anybody help me to realize to what context is std::thread supported in MSVC11

12
  • 2
    I can use std::thread perfectly fine in VS2012. Commented Jan 8, 2013 at 12:27
  • 1
    "there appears to be nothing for a compiler implementation to do (at least, one that already supported multithreading". The author could have said, "multi-threading, with a memory model that makes at least all of the guarantees that C++11 makes about avoiding data races". There could in principle be a C++03 implementation with a different memory model, that makes weaker guarantees, and then there would be work to do in that compiler. But C++11 was designed with existing (major) threading implementations in mind. Commented Jan 8, 2013 at 12:32
  • 2
    Also, I think the author is distinguishing between nothing for a compiler to do vs nothing to do in the libraries. So adding <thread> isn't a compiler change, as far as that author is concerned, and it's not part of the "memory model" line item. It's a library change. I think that for pretty much any C++03 implementation on which boost::thread was already implemented, you can implement std::thread too without compiler changes, just provide the right interface in the right header. Commented Jan 8, 2013 at 12:33
  • 1
    @YamenAjjour It is just that noone would deduce information about supported library features from just a statement about a totally different compiler feature. That's why it is not misleading. Commented Jan 8, 2013 at 13:08
  • 2
    @ChristianRau: "having std::thread present probably tells us that the implementation cares for multithreading and thus realizes the memory model" -- although implementations can always pull a fast one on you, and make the threading header available always but only realize the memory model if you remember to compile with -pthread ;-) Commented Jan 8, 2013 at 13:15

3 Answers 3

8

it says about Concurreny Memory Model

The "Concurrency Memory Model" is not std::thread. The Concurrency Memory Model is language in the standard that explains how variables behave in the presence of threads. Any threads, whether they come from std::thread or OS threads or whatever.

Sign up to request clarification or add additional context in comments.

2 Comments

Finally someone who gives a proper answer, explaining the initial problem problem of the question. +1
just to give an example, according to c++11 static variables in functions should be thread safe, but they are not in VC11 afaik.
5

What it basically says is that MSVC already supported threading before, so there was nothing to do except add the Standard wrappers. So it's quite fine to use.

Comments

1

Yes but there are known bugs:
http://www.justsoftwaresolutions.co.uk/news/just-thread-v1.8.0-released.html

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.