Two Plus Two Publishing LLC Two Plus Two Publishing LLC
 

Go Back   Two Plus Two Poker Forums > >

Notices

Programming Discussions about computer programming

Reply
 
Thread Tools Display Modes
Old 03-06-2017, 11:54 AM   #26
RustyBrooks
Carpal \'Tunnel
 
RustyBrooks's Avatar
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 22,797
Re: C++ Threading w/ Boost Library

Quote:
Originally Posted by goofyballer View Post
As someone who just arrived on the "modern C++" scene a couple years ago, lots of Boost stuff (including threads) seems to me like it's been assimilated into or superseded by C++11.
Yeah, really the C++ language was lacking very basic obviously needed features for *years* and boost implemented a bunch of them. The good ones got folded into the C++ standard, and Boost is sort of seen as a proving ground for new features.

I try not to use Boost features, because it really just complicates things needlessly, in terms of compiling and distributing. I try not to use too many libraries at all unless they are really needed and/or widely available.
RustyBrooks is offline   Reply With Quote
Old 03-06-2017, 01:01 PM   #27
leavesofliberty
Pooh-Bah
 
leavesofliberty's Avatar
 
Join Date: Jul 2010
Location: Without the powers of Deep Blue
Posts: 4,999
Re: C++ Threading w/ Boost Library

Quick question, how do you know what to link to?

Code:
#include <boost/interprocess/managed_shared_memory.hpp>
#include <cstdlib> //std::system
#include <sstream>
And, I should be linking to what?

Also, just getting back into C++, didn't realize that much of it is adopted in newer versions.

Interesting, just noticed that when I did the re-install I did not do the step

Code:
./b2 install
Putting all the files in /usr/local/lib

Now that the files are there, it does not work. But, when the files are not there it does work!

Last edited by leavesofliberty; 03-06-2017 at 01:21 PM.
leavesofliberty is offline   Reply With Quote
Old 03-06-2017, 02:03 PM   #28
leavesofliberty
Pooh-Bah
 
leavesofliberty's Avatar
 
Join Date: Jul 2010
Location: Without the powers of Deep Blue
Posts: 4,999
Re: C++ Threading w/ Boost Library

Did an example with chrono.cpp from this link. https://theboostcpplibraries.com/boost.chrono

I think specifically there's a bug in the sleep_for function that happens only when using the linked package.
leavesofliberty is offline   Reply With Quote
Old 03-06-2017, 04:48 PM   #29
RustyBrooks
Carpal \'Tunnel
 
RustyBrooks's Avatar
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 22,797
Re: C++ Threading w/ Boost Library

You might already have boost installed somewhere else in the system, because it's available as packages from debian etc. In fact, unless you have a specific version to compile it yourself it's probably better to use the official packages for your distro.

How do you know which libraries to link to? Mostly experience. There are some tools you can use depending on your OS. There's a tool called "nm" for example that can be used to dump the symbols in a library. When you go to link and it complains that it can't find a symbol, you can, for example, run nm on all the boost libraries and grep for that symbol. This doesn't always work.
RustyBrooks is offline   Reply With Quote
Old 03-06-2017, 06:14 PM   #30
leavesofliberty
Pooh-Bah
 
leavesofliberty's Avatar
 
Join Date: Jul 2010
Location: Without the powers of Deep Blue
Posts: 4,999
Re: C++ Threading w/ Boost Library

Quote:
Originally Posted by RustyBrooks View Post
You might already have boost installed somewhere else in the system, because it's available as packages from debian etc. In fact, unless you have a specific version to compile it yourself it's probably better to use the official packages for your distro.

How do you know which libraries to link to? Mostly experience. There are some tools you can use depending on your OS. There's a tool called "nm" for example that can be used to dump the symbols in a library. When you go to link and it complains that it can't find a symbol, you can, for example, run nm on all the boost libraries and grep for that symbol. This doesn't always work.
Thanks for your post. I had conflicting installations, different versions, so I had to purge them both, and re-install from source, and also do one command

1. Find the version.

Code:
dpkg -S /usr/include/boost/version.hpp
2. Purge it.

Code:
apt-get remove libboost1.XX-dev
3. Clean the directories.

Code:
rm -r /usr/local/lib/libboost*
4. Deconfig magic.

Code:
ldconfig
5. Re-install from binaries

Code:
tl'dr
after perusing StackOverflow, and it works! Boost is probably a waste of time with C++v11 out. BUT, not going to pick a fight I can't finish.
leavesofliberty is offline   Reply With Quote
Old 03-08-2017, 02:45 AM   #31
DarkMagus
Carpal \'Tunnel
 
DarkMagus's Avatar
 
Join Date: Jul 2007
Location: Vancouver, BC
Posts: 7,952
Re: C++ Threading w/ Boost Library

Ya my code at work includes a whole pile of stuff written years ago that uses boost, most of which could now use the std:: versions.

boost is a lot less necessary now, there are still some useful libraries (we use Asio for example) but generally look to the std library first for stuff and only use boost if it's not there (or if you're in the unfortunate position of having to maintain old code that uses a lot of boost :P)

Last edited by DarkMagus; 03-08-2017 at 02:53 AM.
DarkMagus is offline   Reply With Quote
Old 03-08-2017, 12:57 PM   #32
leavesofliberty
Pooh-Bah
 
leavesofliberty's Avatar
 
Join Date: Jul 2010
Location: Without the powers of Deep Blue
Posts: 4,999
Re: C++ Threading w/ Boost Library

Quote:
Originally Posted by DarkMagus View Post
Ya my code at work includes a whole pile of stuff written years ago that uses boost, most of which could now use the std:: versions.

boost is a lot less necessary now, there are still some useful libraries (we use Asio for example) but generally look to the std library first for stuff and only use boost if it's not there (or if you're in the unfortunate position of having to maintain old code that uses a lot of boost :P)
I've decided not to use Boost, except when absolutely necessary, probably when I get to where I need Asio. Thanks goofyballer, RustyBrooks, et. al.
leavesofliberty is offline   Reply With Quote
Old 03-14-2017, 10:48 AM   #33
Xsaa
newbie
 
Join Date: Mar 2017
Posts: 29
Re: C++ Threading w/ Boost Library

Why not just use pthread? Comes with any sort of linux.
Google "yolinux posix thread" for a really good tutorial on multi-threading.
Xsaa is offline   Reply With Quote
Old 05-19-2017, 09:37 AM   #34
leavesofliberty
Pooh-Bah
 
leavesofliberty's Avatar
 
Join Date: Jul 2010
Location: Without the powers of Deep Blue
Posts: 4,999
Re: C++ Threading w/ Boost Library

Quote:
Originally Posted by Xsaa View Post
Why not just use pthread? Comes with any sort of linux.
Google "yolinux posix thread" for a really good tutorial on multi-threading.
Thanks, I will look into it. So far I am using straight C.
leavesofliberty is offline   Reply With Quote
Old 05-19-2017, 04:30 PM   #35
adios
Carpal \'Tunnel
 
Join Date: Sep 2002
Location: Good places
Posts: 20,617
Re: C++ Threading w/ Boost Library

Quote:
Originally Posted by leavesofliberty View Post
Thanks, I will look into it. So far I am using straight C.
C 11 and C++ 11 have a concurrency model now. Easier to code and probably more portable than pthreads. Nothing wrong with learning pthreads though.

Stack Overflow link on C 11 and C++ 11 concurrency.
adios is offline   Reply With Quote
Old 05-20-2017, 01:35 PM   #36
leavesofliberty
Pooh-Bah
 
leavesofliberty's Avatar
 
Join Date: Jul 2010
Location: Without the powers of Deep Blue
Posts: 4,999
Re: C++ Threading w/ Boost Library

Quote:
Originally Posted by adios View Post
C 11 and C++ 11 have a concurrency model now. Easier to code and probably more portable than pthreads. Nothing wrong with learning pthreads though.

Stack Overflow link on C 11 and C++ 11 concurrency.
Many thanks. Definately getting up to spead. Working on AI and multiplayer games so have to learn everything I can about modern threading techniques first and network programming.
leavesofliberty is offline   Reply With Quote
Old 05-20-2017, 01:51 PM   #37
adios
Carpal \'Tunnel
 
Join Date: Sep 2002
Location: Good places
Posts: 20,617
Re: C++ Threading w/ Boost Library

Quote:
Originally Posted by leavesofliberty View Post
Many thanks. Definately getting up to spead. Working on AI and multiplayer games so have to learn everything I can about modern threading techniques first and network programming.
C++ Concurrency in Action

This is a good book on the topic. If you search around enough on the webs you can find a PDF version and that with a Kindle will get you the book for free.

I would also recommend Herb Sutter's articles on concurrency. These are more about how to design code to tackle problems where concurrency is needed.
adios is offline   Reply With Quote
Old 05-20-2017, 02:09 PM   #38
leavesofliberty
Pooh-Bah
 
leavesofliberty's Avatar
 
Join Date: Jul 2010
Location: Without the powers of Deep Blue
Posts: 4,999
Re: C++ Threading w/ Boost Library

Thanks, ordered it on Amazon. Paper is easier on the eyes.
leavesofliberty is offline   Reply With Quote

Reply
      

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Forum Jump


All times are GMT -4. The time now is 09:50 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Search Engine Optimisation provided by DragonByte SEO v2.0.33 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Copyright ę 2008-2010, Two Plus Two Interactive
 
 
Poker Players - Streaming Live Online