none
Problem with std::thread RRS feed

  • Question

  • Hi!

    Could someone answer my question, please?

    I have a class that has its own thread.

    struct CThread1 abstract : boost::noncopyable { CThread1() throw() {}; CThread1( CThread1 && Source ) throw(); CThread1 & operator = ( CThread1 && Source ) throw(); virtual ~CThread1() throw(); void RunThread(); virtual void Routine() throw() = 0;

    private: std::thread mThread; };

    It has a destructor:

    CThread1::~CThread1() { if( mThread.joinable() ) mThread.join(); }

    The problem is, that this class never exits join() method,

    but the thread's routine is finished.

    It looks like this bug:

    connect.microsoft.com

    The difference is, that my instance is a local variable (on the stack stack)

    In main function it should be closed correctly.

    P. S.

    Maybe this is a bug, but how to create the code without the problem?

    Would it be solved, may I wait for a better runtime,

    or is it my error?

    Thank you very much


    Włodzimierz O. Kubera


    Sunday, June 9, 2013 1:15 PM

Answers

  • I must verify the problem another time.

    It looks like, that something has changed

    and this is not the bug found on the connect site.


    Włodzimierz O. Kubera

    • Marked as answer by Kubera-Info Monday, June 10, 2013 5:07 AM
    Monday, June 10, 2013 5:07 AM

All replies

  • I must verify the problem another time.

    It looks like, that something has changed

    and this is not the bug found on the connect site.


    Włodzimierz O. Kubera

    • Marked as answer by Kubera-Info Monday, June 10, 2013 5:07 AM
    Monday, June 10, 2013 5:07 AM
  • I stumbled over a similar problem, but could only reproduce it when the std::thread is used as part of an object that is created (and destructed) as "global variable".

    My assumption is that using an instance that implements your abstract CThread1 class will produce a deadlock on application exits when the instance is declared as (1) global static object or static member of a function (when compiled e. g .with VS2013 Update 4). See this thread for details.

    Wednesday, March 15, 2017 10:17 AM