class Poco::ThreadTarget

Overview

This adapter simplifies using static member functions as well as standalone functions as targets for threads. Moreā€¦

#include <ThreadTarget.h>

class ThreadTarget: public Poco::Runnable
{
public:
    // typedefs

    typedef void (*Callback)();

    // construction

    ThreadTarget(Callback method);
    ThreadTarget(const ThreadTarget& te);

    // methods

    ThreadTarget&
    operator=(const ThreadTarget& te);

    virtual
    void
    run();
};

Inherited Members

public:
    // methods

    virtual
    void
    run() = 0;

Detailed Documentation

This adapter simplifies using static member functions as well as standalone functions as targets for threads.

Note that it is possible to pass those entities directly to Thread::start(). This adapter is provided as a convenience for higher abstraction level scenarios where Runnable abstract class is used.

For using a non-static member function as a thread target, please see the RunnableAdapter class.

Usage:

class MyObject
{
    static void doSomething() {}
};
ThreadTarget ra(&MyObject::doSomething);
Thread thr;
thr.start(ra);

or:

void doSomething() {}

ThreadTarget ra(doSomething);
Thread thr;
thr.start(ra);

Methods

virtual
void
run()

Do whatever the thread needs to do.

Must be overridden by subclasses.