Opened 9 years ago

Closed 9 years ago

#9632 closed Bugs (fixed)

public method start_thread in boost::thread class

Reported by: dinazil@… Owned by: viboes
Milestone: Boost 1.56.0 Component: thread
Version: Boost 1.53.0 Severity: Problem
Keywords: Cc:

Description

There's a public method start_thread in the thread class. I couldn't find in the documentation what this method does.

In my code I accidentally called this method and it resulted in my callback being started twice.

Since calling the constructor implicitly starts the thread, I don't understand why such method should exist. I think that in one of the earlier versions of boost this was a private method. Is it possible that this method became public by mistake?

Change History (5)

comment:1 by viboes, 9 years ago

Owner: changed from Anthony Williams to viboes
Status: newassigned

Yes this is an error, it must be private. I will fix it.

comment:2 by viboes, 9 years ago

This patch should solve the issue.

git diff ../include/boost/thread/detail/thread.hpp
diff --git a/include/boost/thread/detail/thread.hpp b/include/boost/thread/detail/thread.hpp
index 2434723..5053b8d 100644
--- a/include/boost/thread/detail/thread.hpp
+++ b/include/boost/thread/detail/thread.hpp
@@ -172,7 +172,7 @@ namespace boost
     private:
         bool start_thread_noexcept();
         bool start_thread_noexcept(const attributes& attr);
-    public:
+    //public:
         void start_thread()
         {
           if (!start_thread_noexcept())

Please, could you confirm if you don't find any regression with it?

comment:3 by viboes, 9 years ago

Milestone: To Be DeterminedBoost 1.56.0

comment:4 by dinazil@…, 9 years ago

This works for me (if I change just the .hpp file), but I didn't try compiling all of boost with this change. thanks!

Note: See TracTickets for help on using tickets.