Register for your free account! | Forgot your password?

You last visited: Today at 15:23

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



C++ Threading

Discussion on C++ Threading within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
C++ Threading

Anybody got some good threading tutorials in c++?

#Edit

Using boost would be fine?
I don't have a username is offline  
Old 03/09/2012, 09:25   #2
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,211
Received Thanks: 4,114
ANSI C++ doesn't support multithreading.
Try looking up how to approach it using Microsoft's libraries.
Spirited is offline  
Old 03/09/2012, 09:40   #3
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
Quote:
Originally Posted by Fаng View Post
ANSI C++ doesn't support multithreading.
Try looking up how to approach it using Microsoft's libraries.
I'm using C::B with GNU GCC.

Been looking at boost:


Also, isn't ANSI just C?
I don't have a username is offline  
Old 03/09/2012, 13:20   #4
 
tkblackbelt's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 266
Received Thanks: 85
Have a look at Qt it has a great and easy to use threading library. Qt's documentation is also very good for learning from.
tkblackbelt is offline  
Thanks
1 User
Old 03/09/2012, 18:06   #5
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
Quote:
Originally Posted by tkblackbelt View Post
Have a look at Qt it has a great and easy to use threading library. Qt's documentation is also very good for learning from.
**** Qt is great, thanks.
I don't have a username is offline  
Old 03/09/2012, 19:13   #6
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,882
There's no standard for multi-threading in C++ (or atleast I don't think there is). If your aim is cross-platform threading, I'd take a look at boost's library.
InfamousNoone is offline  
Thanks
1 User
Old 03/09/2012, 20:43   #7
 
Nullable's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 390
Received Thanks: 321
^That, or make the transition to C++11. Totally worth it.
Nullable is offline  
Thanks
1 User
Old 03/09/2012, 23:44   #8
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
Thanks everyone, taking a look
I don't have a username is offline  
Old 03/10/2012, 05:40   #9
 
XMasterrrr's Avatar
 
elite*gold: 0
Join Date: Nov 2008
Posts: 357
Received Thanks: 250
as the above,

want to write in complete-native c++ use boost or C++11.

want to write with great graphical framework and libraries use QT.

if i were you i would use QT
XMasterrrr is offline  
Thanks
1 User
Old 03/10/2012, 15:47   #10


 
CptSky's Avatar
 
elite*gold: 0
Join Date: Jan 2008
Posts: 1,434
Received Thanks: 1,147
I would go for Boost before Qt. Boost is more an extension to the current standard libraries than Qt. Qt is a big framework for advanced concepts like the GUI. Else, you can easily write your own threading wrapper that will be defined by the platform and using the platform API. It's what I do for file handling and unicode. (I try to make a project without any external libraries. Else, I would use boost and iconv)

All these solutions are equivalent... They are all multi-platform and they will all use the system call interface of the OS as the threading is controlled by the kernel.

N.B. Is Boost working fine? I know that some time ago, as it was compliant to new standards, you where getting bunch of errors.
CptSky is offline  
Thanks
2 Users
Old 03/11/2012, 18:54   #11
 
Mr_PoP's Avatar
 
elite*gold: 0
Join Date: Apr 2008
Posts: 759
Received Thanks: 285
I guess C++11 will be better to use in order to make a multithreading app , it's like C# tho!

Code:
void do_work();
std::thread t(do_work);
for more info
Mr_PoP is offline  
Thanks
1 User
Old 03/12/2012, 21:53   #12


 
KraHen's Avatar
 
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 793
You could also consider POSIX threads, they should be working under win32 as well, at least with Cygwin they probably do.
KraHen is offline  
Thanks
2 Users
Old 03/13/2012, 09:35   #13
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
I will take a look, thanks everyone
I don't have a username is offline  
Old 03/24/2012, 15:58   #14


 
KraHen's Avatar
 
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 793
I have done some testing while currently working on my C++ port of my old source, and have found that in a Win32 enviroment CreateThread works definitely better and faster than POSIX threads. This was expected though, lol. Just a notice. Though you shouldn`t use CreateThread, better use the C runtime version _beginthreadex(). Boost threads win hands-down.
KraHen is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
Threading
11/18/2011 - CO2 Private Server - 10 Replies
What should I do? A thread for every map that's used by players, a global thread for all players or a single thread for every player.
Multi Threading
08/18/2011 - CO2 Private Server - 6 Replies
I know it's not Conquer related like that, but Multi Threading is a very big part, when developing Conquer PServers. Source: Managed Threading Best Practices
Socket/Threading Question
07/31/2011 - CO2 Programming - 3 Replies
Alright so I've been following InfamousNoone's C# for idiots tutorial (video set) and I've just finished watching them all. I can now say I'm very very interested in sockets and whatnot. So the problem is, I'm trying to use sockets to creating a mini Messaging client and I've gotten to the point where I can send a message back in forth. But this is how it works. The ONLY way you can send a message is if you receive one first. That's obviously a problem! I've tried to start multiple threads...
[C++] Problem with threading
05/17/2009 - CO2 Programming - 2 Replies
Actually the problem is more like with passing a function as pointer to the CreateThread or _beginthreadex, BOOL Connect() { if(m_Enabled != TRUE) return FALSE; sockaddr_in addr; addr.sin_family = AF_INET;
[C#] Cross-Threading ?
10/14/2008 - .NET Languages - 7 Replies
Hello, Is there a flag or whatever that lets me use crossthreading freely? Without the help of a Workerthread. Whenever I try to change a variable it doesn't let me because Crossthreading isn't safe (eg. accessing the variables from other threads), but It's also hard to find a solution for this. I'm starting another thread that contains a function to download the source code of another page and process the wanted information into variables, however I cannot do that with a thread. The only...



All times are GMT +2. The time now is 15:23.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.