Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

All LUA functions that are invoked by server tasks as well as all predefined event callbacks (cf. Section 4.6.11) are called in the same thread context. This means that these functions are not executed independent of each other – they are executed one by one. Especially if a lot of functionality is implemented in a LUA function i.e. if it contains a lot of LUA code, this may be a disadvantage because a long execution of a LUA function may block other LUA function.
In order to be able to implement time consuming tasks, so called LUA Apps are available. LUA Apps are executed
within a separate thread within the LUA engine. This means that LUA Apps are executed to some extend in parallel without block each other.
LUA Apps are invoked using the following LUA function: <file name="nxa.StartApp">
<h1>Description</h1>
<h1>Signature</h1>

Description

Signature

nxa.StartApp (LUA file, LUA function) <p>

Start a LUA App in a separate thread context. </p>
<h1>Parameters</h1>
<table>
<colgroup> <col/> <col/> <col/> <col/> </colgroup>
<tbody>
<tr>
<th>Name</th>
<th>Type</th>
<th>Mandatory/Optional</th>
<th>Description</th>
</tr>
<tr><td></td><td>LUA file</td><td>M</td><td>name

Parameters

NameTypeMandatory/OptionalDescription
 LUA fileMname of the LUA file where the function is

...

defined
 LUA functionMLUA worker function that is invoked within a separate

...

thread

Return

None.


After calling the "nxa.StartApp", the given function is executed as App. If the function is returns, the App is automatically terminated. This means if a LUA App shall be able to do some periodic task, an event loop has to be included.
Since LUA Apps are invoke to some extent in parallel, the implemented functionality and the used resource must be thread-safe i.e. critical operations must be protected. Therefore, only the following functions can be used within LUA Apps:

...