Boost logo

Boost Users :

Subject: Re: [Boost-users] Who can give me a sample for how to using boost::thread in a MFC regular dll?
From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2010-04-21 10:17:02


DDGG <ddcatgg_at_[hidden]> writes:

> You are very kind, thank you for your help!
> I have found the solution, at the last reply of this:
> http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/ec0ce12e-d54d-4b6a-944e-62dd8bb76b7d
>
> // extern BOOL (WINAPI * const _pRawDllMain)(HANDLE, DWORD,
> LPVOID)=&dll_callback;
> I commented it and recompiled the boost library, and then the problem
> disappeared.

If you do that then you are liable to leak memory and potentially
resources if you use any boost.thread facilities from any thread not
started with boost::thread. In particular, boost::thread_specific_ptr
variables will not be destroyed when a non-boost::thread thread exits,
but other uses of the boost thread library may also leak memory.

The best option in this case is to use the DLL build of boost.thread.

Anthony

-- 
Author of C++ Concurrency in Action     http://www.stdthread.co.uk/book/
just::thread C++0x thread library             http://www.stdthread.co.uk
Just Software Solutions Ltd       http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976

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