[Home]Suggestions - Thread Library

BOOST WIKI | RecentChanges | Preferences | Page List | Links List

This page is for suggestions for improvements to the Boost Thread Library.

Back to thread library pages


Add trait for non-destructing thread_specific_ptr

Currently, when you set thread-specific storage with:

    thread_specific_ptr<mystruct> val;
    ...
    val.reset(ptr);

then, when the thread dies, delete is automatically invoked on ptr. This can be problematical.

It would be nice if there were a version of thread_specific_ptr which didn't delete on exit. It would be natural to implement this with a trait, e.g.:

    thread_specific_ptr<mystruct, non_deleting> val;

    - People/Chuck Messenger


Could it be solved using a secondary template argument to reset, as shared_ptr?

    thread_specific_ptr<mystruct> val;
    val.reset(new int[47], some_argument_here)

    - People/Anders Dalvander


Why Do you think it is problematic? After the thread has gone noone can get access to the pointer anyhow. This is what TLS is for.

Of course this is not true if you try to access the pointer also from a second thread. Avoid this, as this is misusing the concept of TLS.

Roland


BOOST WIKI | RecentChanges | Preferences | Page List | Links List
Edit text of this page | View other revisions
Last edited November 5, 2004 5:01 am (diff)
Search:
Disclaimer: This site not officially maintained by Boost Developers