#include <BThread.h>
Inheritance diagram for BThread:

It provides a mutex and a signal(condition), and some functionality helping with joining the thread. The derived function should implement the void ThreadFunction() function with the code that should be executed in the thread.
The following example shows a simple thread that uses BThread:
class SimpleThread : public BThread { public: SimpleThread() : ran(false) {} bool Ran() { return ran; } private: volatile bool ran; virtual void ThreadFunction() { ran = true; } }; // end class SimpleThread // this is the main function of the test void basic_test() { SimpleThread t; t.Start(); t.Join(); BOOST_CHECK(t.Ran() == true); } // end void basic_test()
In the following example, the main thread is synchronizing with the worker thread via the thread's signal:
Public Member Functions | |
| virtual | ~BThread () |
| The thread should be joined by the time the destructor is called. | |
| void | Join () |
| Joins the thread (i.e., this function will not return until the thread finishes). | |
| void | Start () |
| Activates the thread. | |
Protected Member Functions | |
| BThread () | |
| Default constructor. Does not start the thread. | |
| virtual void | ThreadFunction ()=0 |
| This function is executed in the new thread when it is started. | |
| bool | Terminating () |
| Returns true if the thread is being joined (the thread should finish). | |
Protected Attributes | |
| boost::mutex | mutex_ |
| Class mutex. | |
| volatile bool | terminating |
1.5.1-p1