RunIndependently (Daemon subroutine): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (update syntax terms to match corrected template)
m (update syntax terms to match corrected template)
Line 18: Line 18:
   
   
<dt><var>[[DaemonLost_class|DaemonLost]]</var>  
<dt><var>[[DaemonLost_class|DaemonLost]]</var>  
<dd>If the <var>daemon</var> object is lost (probably restarted), a <var>DaemonLost</var> exception is thrown. Since <var>RunIndependently</var> does not wait for the <var>daemon</var> thread to do anything, a <var>DaemonLost</var> exception indicates that the <var>daemon</var> thread was lost <b><i>before</i></b> <var>RunIndependently</var> was invoked. This exception will only be thrown in <var class="product">[[Sirius Mods|"Sirius Mods"]]</var> Version 7.2 and later.
<dd>If the <var>daemon</var> object is lost (probably restarted), a <var>DaemonLost</var> exception is thrown. Since <var>RunIndependently</var> does not wait for the <var>daemon</var> thread to do anything, a <var>DaemonLost</var> exception indicates that the <var>daemon</var> thread was lost <b><i>before</i></b> <var>RunIndependently</var> was invoked. This exception will only be thrown in <var class="product">[[Sirius Mods|Sirius Mods]]</var> Version 7.2 and later.
</dl>
</dl>


Line 29: Line 29:
<li>No <var>daemon</var> class mechanism is provided for a parent thread to retrieve the output from an independently running <var>daemon</var>.
<li>No <var>daemon</var> class mechanism is provided for a parent thread to retrieve the output from an independently running <var>daemon</var>.
<li>As described in [[Daemon class]], <var>RunIndependently's</var> <var class="term">string</var> argument can pass multiple commands to the <var>daemon</var>.  
<li>As described in [[Daemon class]], <var>RunIndependently's</var> <var class="term">string</var> argument can pass multiple commands to the <var>daemon</var>.  
<li><var>RunIndependently</var> was introduced in <var class="product">[[Sirius Mods|"Sirius Mods"]]</var> Version 7.0.  
<li><var>RunIndependently</var> was introduced in <var class="product">[[Sirius Mods|Sirius Mods]]</var> Version 7.0.  
</ul>
</ul>



Revision as of 17:46, 4 May 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.