Starting the message-dispatching execution thread

auto clinstance = myClass::create();


x::start_threadmsgdispatcher must be used to start an execution thread for a subclass of x::threadmsgdispatcherObj. x::start_threadmsgdispatcher() is a wrapper for x::run(). The first parameter to the execution thread's run() message is a reference to an opaque mcguffin. Any remaining parameters to x::start_threadmsgdispatcher() get forwarded as additional parameters to the thread's run() method:

    void run(x::ptr<x::obj> &threadmsgdispatcher_mcguffin)
        msgqueue_auto msgqueue(this);


        try {
            while (1)

        } catch (const x::stopexception &)
        } catch (const x::exception &e)

The execution thread's run() method takes the following actions:

x::start_threadmsgdispatcher() does not return until the new execution thread destroys the mcguffin. This is why the mcguffin parameter gets passed to run() by reference, rather than value. This ensures that the new threads message queue exists after x::start_threadmsgdispatcher() returns.