template<class ThreadMaster>
class uniset::OmniThreadCreator< ThreadMaster >
- Шаблон для создания потоков с указанием функции вызова. Пример использования:
class MyClass
{
public:
MyClass();
~MyClass();
execute();
protected:
void thread();
private:
OmniThreadCreator<MyClass>* thr;
};
MyClass::MyClass()
{
thr = new OmniThreadCreator<MyClass>(this, &MyClass::thread);
}
MyClass::~MyClass()
{
delete thr;
}
void MyClass::thread()
{
while(active)
{
}
}
void MyClass::execute()
{
thr->start();
}
main()
{
MyClass* mc = new MyClass();
mc->execute();
OmniThreadCreator<MyClass>* th = new OmniThreadCreator<TestClass>(&mc, &MyClass::thread);
th->start();
}