Search code examples
boostmultithreadingexit-code

boost::thread exit code?


What is the standard way to get an exit code from a boost::thread ?
The docs don't seem to touch on this subject at all.


Solution

  • I don't know that the thread exit code is available as that's operating system specific. You could simulate passing an exit code or result code by doing something like this:

    struct callable {
        int result;
        void operator()()
        {
            result = 42;
        }
    };
    
    void process_on_thread() {
        callable x;
        boost::thread processor(x);
    
        processor.join();
        int result = x.result;
    }