Horde3D http://horde3d.org/forums/ |
|
C++ Boost libraries ? http://horde3d.org/forums/viewtopic.php?f=5&t=491 |
Page 1 of 1 |
Author: | Siavash [ 04.09.2008, 15:11 ] |
Post subject: | C++ Boost libraries ? |
C++ Boost libraries are too popular these days. They offer comfortable libraries for C++ programmers [depending on google and wikipedia] I've seen some examples about multithreading with them; Multithreading with C++ Boost is too similar with high level languages such as C# .net Is there anybody that have some experience with them ? Please write your experiences and it's benefits |
Author: | swiftcoder [ 04.09.2008, 16:25 ] |
Post subject: | Re: C++ Boost libraries ? |
You would probably be better off posting this type of question on a more general forum - GameDev.net is one of the best and largest, and quite a few of us from these forums also hang out there. |
Author: | phoenix64 [ 04.09.2008, 18:29 ] |
Post subject: | Re: C++ Boost libraries ? |
I'd say they are bloated Never used them though. |
Author: | swiftcoder [ 04.09.2008, 20:15 ] |
Post subject: | Re: C++ Boost libraries ? |
I use certain aspects of Boost pretty extensively. The threading library is excellent, the smart pointer and container libraries are already in the C++ TR1 and TR2 specs and are essential to writing robust, maintainable C++ code. Spirit is a very useful parser framework, Phoenix and MPL are excellent for meta-programming both at the template and macro level. All in all, Boost brings C++ somewhere close to the ease of use of a more modern language such as C# or Objective-C, but even so, C++ doesn't (and really can't) ever attain that. |
Author: | gunnar [ 05.09.2008, 08:56 ] |
Post subject: | Re: C++ Boost libraries ? |
Well, for starters, I find boost::python excellent. It may be that I'm doing something conceptually very wrong, but I find the python<->C++ interaction very easy to work with when using boost::python. It took me something like 50 lines of code to connect my C++ renderer, and PyCairo to create 2D vector graphics textures in python. I have also worked with the boost thread libraries, and it took me practically no code to create a base class that allowes me to use threads Java style. Example base class: Code: #include <boost/thread/thread.hpp> #include <boost/thread/mutex.hpp> #include <boost/thread/xtime.hpp> #include <boost/shared_ptr.hpp> #include <boost/progress.hpp> #include <boost/bind.hpp> #include <boost/thread/condition.hpp> #include <boost/utility.hpp> #include <iostream> /** */ class Thread : private boost::noncopyable { private: boost::condition thread_condition; boost::mutex monitor; /** */ virtual void __run() { std::cout << "before run()" << std::endl; run(); std::cout << "after run()" << std::endl; delete this; } public: /** */ virtual void run() = 0; /** */ virtual void sleep(const int nseconds) { boost::xtime t; boost::xtime_get(&t, boost::TIME_UTC); t.nsec += nseconds; boost::thread::sleep(t); } /** */ virtual void start() { boost::thread th(boost::bind(&Thread::__run, this)); } protected: /** */ virtual void wait() { boost::mutex::scoped_lock thread_lock(monitor); thread_condition.wait(thread_lock); } /** */ virtual void notify() { thread_condition.notify_one(); } Thread() { std::cout << "Thread created." << std::endl; } virtual ~Thread() { std::cout << "Thread destroyed." << std::endl; } }; And example of derived class: Code: /** */
class MyThread : public Thread { private: int id; public: MyThread(int _id) : id(_id) {} /** */ void run() { std::cout << "Thread[" << id << "] starting.." << std::endl; sleep(2); std::cout << "Thread[" << id << "] waiting.." << std::endl; wait(); std::cout << "Thread[" << id << "] notified. done." << std::endl; } /** */ void doStuff() { notify(); } private: ~MyThread() { std::cout << "Thread[" << id << "] destroyed." << std::endl; } }; |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |