|
Boost Users : |
From: Bryan Green (bryan.d.green_at_[hidden])
Date: 2008-05-23 13:37:26
Hi,
I have been converting some of my pthread-code to boost::thread,
and I commonly use thread-specific storage to store a pointer that is
not intended to be deleted when the thread exits (the default action for
thread_specific_ptr). In pthreads, specifying NULL as the cleanup_function
accomplishes what I want, i.e. no cleanup is done. In boost::thread,
specifying NULL will crash my program, because the implementation does not
test for a null cleanup_function before invoking it.
Since the cleanup function for thread_specific_ptr<T> takes an argument of
type T*, this means that whereever I use thread_specific_ptr in this way, I
have to define an empty function taking T*, to pass as the cleanup function.
It seems pretty messy and wasteful to me, when all that is needed is a
(cleanup_function != 0) test in the implementation.
Is there a rationale for boost::thread not supporting a NULL
cleanup_function pointer?
Thanks,
-bryan
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