This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: deciding threading support at compile time


Hi Christoph,

You asked...
How can a library writer reliably decide in a header file whether the program is to support multithreading?


The answer appears to be:

Document that some define is required when used in conjunction with your header file that enables multithreading facilities, such as mutex protection, necessary for safe multithreaded operation of your library.

For instance, maybe something like -DBOOST_POSIX_THREADS would be appropriate.

Also of interest is another approach, that taken by Doug Schmidt's ACE (http://www.cs.wustl.edu/~schmidt/ACE.html). Therein, he punted* by allowing the POLICY level decision of mutex protection to be at the discretion of the library user, by making the mutex a template object that could (possibly) be a null_mutex.

HTH,
--Eljay

* Or if you think Doug's idea was a good one (as I do), replace "punted" with "was inspired".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]