Boost logo

Boost :

From: David Brownell (david_brownell_at_[hidden])
Date: 2003-03-26 18:53:25


> // In library Foo
>
> void some_library_foo()
> {
> boost::thread_specific_ptr<Foo> p;
> // other stuff
> }
>
> // In Application Bar which uses library Foo with out any knowledge
> // that Foo used Boost.Threads
> void bar()
> {
> some_library_foo();
> }
>
> int main()
> {
> __beginthread(&bar, ....); // leak, but how could the developer know?
> }
>

I'm not sure I understand this example completely. Is this the case where
library Foo's author has created the some_library_foo function with the
intention that it will be accessed by a thread, but leave the actual thread
creation up to the user of the foo library (the bar application in your
example)?

If this is correct, it seems like Foo should either a) not burden Bar with
the knowledge that threads are being used and handle thread creation itself
or b) allocate locally to some_library_foo without using
thread_specific_ptr.

William, thank you for taking the time to answer these questions so
promptly, I appreciate your help! Also, if it would be beneficial to take
this discussion offline, I am open to that as well.

David


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk