<thread> run a thread

name
thread
xml namespace
http://moyaproject.com

Run enclosed block in a thread.

When Moya encounters this tag it executes the enclosed code in a new thread. The calling thread will jump to the end of the <thread> tag.

The enclosed code may return a value (with <return>), which can be retrieved by the calling thread via it's dst parameter. If the calling thread references the return value before the thread has returned, it will block until the thread returns.

This tag is useful in a request when you have some long running action to do, and you don't want to delay returning a response. Here's an example:

<view libname="view.process" template="slowprocess.html">
    <thread>
        <call macro="slow"/>
    </thread>
</view>

This view will render a template and return immediately, while the macro is processing in the background. Note, that the slow macro will have no way of returning anything in the response, but could still send an email or store something in the database to communicate the result to the user.

attributes
name purpose type required? default choices
join Join threads before end of request? boolean No no
name Name of thread text No
scope Use the current scope? boolean No no
timeout Maximum time to wait for thread to complete timespan No
inherited attributes
name purpose type required? default choices
dst Destination reference No
if Conditional expression expression No yes
value Value expression No None