boost

Is there a disadvantage to using boost::interprocess::interprocess_semaphore within a single multithreaded c++ process?

The disadvantage would be in comparison to a technique that was specialized to work on threads that are running within the same process. For example, does wait/post cause the whole process to yield, rather than just the executing thread, even though anyone waiting for a post would be within the same process? The semaphore would be used,...

Boost Serialize - Serialize data in a custom way

If I'm using Boost Serialization to serialize an Integer: #include <boost/archive/text_oarchive.hpp> #include <iostream> int main() { boost::archive::text_oarchive oa(std::cout); int i = 1; oa << i; } The result will be the following: 22 serialization::archive 5 1 Now I'm curious if and how I could change the way, certa...

how to resolve ftp site using boost.asio?

Hello: Boost.asio documentation doesn't support any ftp examples. `boost::asio::io_service io_service; tcp::resolver resolver(io_service); tcp::resolver::query query("www.boost.org", "http"); tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);` that resolve http site and get an HTTP endpoint. but tcp::resolver::que...

C++ - binding function

Hello! I have some (library API, so I can't change the function prototype) function which is written the following way: void FreeContext(Context c); Now, at some moment of my execution I have Context* local_context; variable and this is also not a subject to change. I wish to use boost::bind with FreeContext function, but I need to ...

How to remove pointer from boost::ptr_vector without object being deleted?

How to exclude pointer from boost::ptr_vector without his deletion? =) ...

boost::filesystem relative path and current directory?

Hi, How can I use boost::filesystem::path to specify a relative path on Windows? This attempt fails: boost:filesystem::path full_path("../asset/toolbox"); // invalid path or directory. maybe to help me debug, how to get the current working directory with boost::filesystem? Thanks. ...

Boost MSM only processing internal transitions

I'm using the new Boost 1.44.0 MSM library to produce a state machine. In this state machine there are two classes of events class1 and class2. class1 events can be processed by either states S1 or S2 while class2 events can only be processed by state S2. A special class1 event upgrade_req requests an upgrade from state S1 to state S2....

calling boost::undirected_dfs from a constant context

I have a class that contains a BGL graph. I'd like to traverse the graph in a constant context. For example, I might want an accessor function to report if the graph is cyclic. As soon as I make my dfs function const the code won't compile. Here's a minimal example: #include <boost/graph/adjacency_list.hpp> #include <boost/graph/undir...

How many threads can I spawn using boost in c++?

And what happens when I try to spawn too many? I'm getting the following error when I spawn more than about 900 threads: terminate called after throwing an instance of 'dining 1 boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::thread_resource_error> >dining 3 ' dining 2 what(): dining 4 boost:...

In a multithreaded c++ program using boost, is there any way to get a pointer to the current thread?

I need to know the identity of the current thread to keep track of which threads are making certain requests to a shared data structure. ...

How can I make sure all of my c++ boost threads finish before the program exits?

I know I can call thread.join() to force a thread to complete before the current thread can proceed. However, my program has a bunch of files that are read into memory, modified, and then flushed to disk. Each flush is being done in a separate thread so that the current thread can continue while the contents are flushed to disk. I could...

How can I extend an embedded python interpreter with C++ functions?

How can I extend an embedded interpreter with C++ code? I have embedded the interpreter and I can use boost.python to make a loadable module (as in a shared library) but I don't want the library floating around because I want to directly interface with my C++ application. Sorry if my writing is a bit incoherent. ...

How can I create a new thread from a c++ boost thread_group that begins execution in a member function of an object?

There are some member variables and mutexes associated with the object, so it would be easier to use a member function rather than a standalone function. ...

Good Book/Training material to learn multithreading in C/C++

Hi, I am just a starter at using threads in my code. I use Boost threads usually. But I don't think I have mastered this field yet. I am looking for learning material specifically for advanced parallel programming. Could anybody suggest something. ...

'stdx’ is not a namespace-name error being shown for a ptr_vector program

I've been trying a program from codeproject, about ptr_vector, and while compiling, the above error is shown. Googling shows no hope to solve this problem. Could anyone here help out? Here's the entire code (am compiling with gcc 4.2.2) #include <iostream> #include <string> #include <boost/ptr_container/ptr_vector.hpp> using namespace ...

Should I use Boost.GIL or is it dead?

I actually like the clean approach of Boost.GIL, standardized libraries are cool and Adobe certainly put some thought in it but when comparing to libs such as OpenCV its feature set is marginal. Do you use GIL and for what purposes? ...

Conditional wait overhead

When using boost::conditional_variable, ACE_Conditional or directly pthread_cond_wait, is there any overhead for the waiting itself? These are more specific issues that trouble be: After the waiting thread is unscheduled, will it be scheduled back before the wait expires and then unscheduled again or it will stay unscheduled until sign...

How do I know what shared variables I need to protect with a lock in c++ using boost?

For example, multithreading would never work if mutexes were not resilient to multithreaded access (e.g., two simultaneous calls to mutex.lock() can't screw things up). Does this extend to condition variables too? Specifically, I want to release a lock and then call cond.notify_one(). Theoretically, another thread could then grab the lo...

Example of using scoped try_shared_lock and upgrade lock in boost

I have a thread pool that is using shared mutexes from the boost library. While the answers to my other question were helpful, http://stackoverflow.com/questions/3896717/example-of-how-to-use-boost-upgradeable-mutexes What I have realised that what I actually need is not to block if a shared lock or upgrade lock could not be obtained. ...

Boost Python and shared_ptr upcast

Sample code for dll/pyd: #include <boost/python.hpp> #include <iostream> class Base { public: Base() {} public: int getValue() { return 1; } }; typedef boost::shared_ptr<Base> BasePtr; class ParentA : public Base { public: ParentA() : Base() {} }; typedef boost::shared_ptr<ParentA> ParentAPtr; class Collector { public: Collect...