Standard Thread Support (C++11)

What it says on the tin: a place to discuss proposed new features.
Post Reply
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
Contact:

Standard Thread Support (C++11)

Post by Klaim » Wed Jan 25, 2012 9:06 am

For those using compilers providing standard <thread> header (C++2011), allowing using std::thread as a threading support would be useful.

I'll take a look at the Ogre code, see if there is a simple way to add it.
0 x

User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
Contact:

Re: Standard Thread Support (C++11)

Post by Klaim » Wed Jan 25, 2012 9:45 am

I started adding a OgreThreadDefineStd.h file with std:: threading types. I copy pasted the boost one to do that as the types from the standard are taken from boost.

However, I've hit a wall : there is no std::shared_mutex in the current (c++11) standard.
Reasons :

- http://stackoverflow.com/questions/4659 ... ared-mutex
- http://stackoverflow.com/questions/5213 ... esources-c

So maybe we'll get it in a future version (TR2) but now, should I can't find an equivalent in the std library so I was thinking about just using a raw std::mutex.
It's not really the same and I'm not experienced enough in this matter to know instinctively if it's fine.
I'll also use unique_lock instead of shared_lock that don't exist either.

I'll go with std::mutex for testing if everything compiles & run fine, but if you have some suggestions, it's welcome...
0 x

CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
Contact:

Re: Standard Thread Support (C++11)

Post by CABAListic » Wed Jan 25, 2012 10:52 am

Well, you've come as far as I have when I tried this...
The problem with exchanging shared_mutex for a standard mutex is that effectively it will disable concurrency. The way the Ogre threading system is built currently, it relies on a multiple reader, single writer lock. Without it, only a single background thread will ever be actively working at the same time.

I'd suggest you don't waste time with it for now. Ogre's threading code is a little too complex right now and needs to change, anyway, if we ever want to multithread more of Ogre's core. Once that's done we can hopefully support std::thread.
0 x

User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
Contact:

Re: Standard Thread Support (C++11)

Post by Klaim » Wed Jan 25, 2012 11:55 am

Oh, ok then, good.
0 x

User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1668
Joined: Mon Jan 21, 2008 10:26 pm

Re: Standard Thread Support (C++11)

Post by madmarx » Sun Jan 29, 2012 2:15 pm

I have developped more than once multiple-read / unique write from simple mutex.
It is really straight forward, there is almost no 'gotcha'.
So if you just want a replacement for that, I think I could do that very easily.
0 x
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0

User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
Contact:

Re: Standard Thread Support (C++11)

Post by Klaim » Sun Jan 29, 2012 11:59 pm

Yes but with std::thread facilities it seems that using futures and promises (in combination with unique_ptr for data) would be far better design and would lead to writing a specific Ogre worker queue for this case...
0 x

nickG
Greenskin
Posts: 122
Joined: Fri Jan 20, 2012 6:44 pm
Location: Russia,Moscow

Re: Standard Thread Support (C++11)

Post by nickG » Sun May 24, 2015 2:54 pm

up!
any news about C++14 threading support in ogre?
0 x

User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
Contact:

Re: Standard Thread Support (C++11)

Post by Klaim » Mon May 25, 2015 1:55 am

0 x

Post Reply