Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost::threads] -D_REENTRANT?
From: Julian Gonggrijp (j.gonggrijp_at_[hidden])
Date: 2011-04-14 12:14:31


Panagiotis Foteinos wrote:

> I am using boost::threads for an application that allocates space in heap with the new operator. Therefore, different threads allocate memory in parallel. Do I have to link my application to any other library apart from the libboost_thread to guarantee a thread safe memory allocation?
> I searched online, but I got more confused. Do I have to define the -D_REENTRANT or the -pthread symbol?

Somebody else could probably provide a much better and much completer
answer, but here's what I think I know. Perhaps you already found the
answer in the meanwhile...

Whether memory allocation is thread-safe depends on your allocator. If
you didn't explicitly specify the allocator you'll be using
std::allocator<yourType>. IIRC, that allocator is thread-safe so you
don't need to worry about additional compiler flags (as far as memory
allocation is concerned).

HTH, Julian


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net