RunIndependently (Daemon subroutine): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (match syntax table to syntax template (will need to be redone when syntax template is fixed) tags and edits)
m (update syntax terms to match corrected template)
Line 6: Line 6:
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%daemon</th>
<tr><th>daemon</th>
<td>A previously defined <var>Daemon</var> object. </td></tr>
<td>A previously defined <var>Daemon</var> object. </td></tr>
<tr><th>string</th>
<tr><th>commands</th>
<td>A string or Stringlist that is the required command or the set of commands executed by the <var>daemon</var>.</td></tr>
<td>A string or <var>[[Stringlist class|Stringlist]]</var> that is the required command or the set of commands executed by the <var>daemon</var>.</td></tr>
<tr><th>inputObj</th>
<tr><th>inputObj</th>
<td>The object passed to the <var>daemon</var> object. This optional argument is passed by deep copy and not by reference, so <var class="term">inputObj</var> must be deep copyable, as described in [[Copying objects|"Copying objects"]].</td></tr>
<td>The object passed to the <var>daemon</var> object. This optional argument is passed by deep copy and not by reference, so <var class="term">inputObj</var> must be deep copyable, as described in [[Copying objects|"Copying objects"]].</td></tr>

Revision as of 23:06, 18 March 2011

Run commands on an independent Daemon thread (Daemon class)

RunIndependently runs on the daemon thread the command or set of commands specified by its first argument. Unlike Run, this method returns immediately, and the thread issuing RunIndependently can run in parallel with the daemon thread. Unlike RunAsynchronously, this method makes the daemon thread completely independent of the parent thread, so the output from the commands can never be retrieved.

Syntax

daemon:RunIndependently( commands, [[Input=] object]) Throws DaemonLost, IncorrectDaemonState

Syntax terms

daemon A previously defined Daemon object.
commands A string or Stringlist that is the required command or the set of commands executed by the daemon.
inputObj The object passed to the daemon object. This optional argument is passed by deep copy and not by reference, so inputObj must be deep copyable, as described in "Copying objects".

Exceptions

RunIndependently can throw the following exceptions:

DaemonLost
If the daemon object is lost (probably restarted), a DaemonLost exception is thrown. Since RunIndependently does not wait for the daemon thread to do anything, a DaemonLost exception indicates that the daemon thread was lost before RunIndependently was invoked. This exception will only be thrown in "Sirius Mods" Version 7.2 and later.

Usage notes

  • Issuing RunIndependently against a transactional daemon results in request cancellation.
  • If the daemon thread and its daemons hold record locks that conflict with the parent thread's family (excluding the daemon thread itself and its daemons ), RunIndependently results in request cancellation.
  • RunIndependently is the rough Daemon class equivalent of the $commbg function.
  • After a RunIndependently method, the daemon object is set to null. This is because the daemon thread runs completely independently of the parent thread once a RunIndependently method is invoked, so there is nothing useful the parent thread can do with such a daemon object, anyway.
  • Even if the parent thread of an independently running daemon logs off, the daemon thread can continue to run.
  • No daemon class mechanism is provided for a parent thread to retrieve the output from an independently running daemon.
  • As described in Daemon class, RunIndependently's string argument can pass multiple commands to the daemon.
  • RunIndependently was introduced in "Sirius Mods" Version 7.0.

Examples

  1. %daem:runIndependently(%list2, %x)

See also

  • See Daemon class for more information about passing commands and objects to a daemon -- the passing of objects and commands to daemons is identical whether the method is Run or RunIndependently.