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)
Line 1: Line 1:
{{Template:Daemon:RunIndependently subtitle}}
{{Template:Daemon:RunIndependently subtitle}}
 
<var>RunIndependently</var> runs on the daemon thread the command or set of commands specified by its first argument. Unlike <var>[[Run_(Daemon_function)|Run]]</var>, this method returns immediately, and the thread issuing <var>RunIndependently</var> can run in parallel with the <var>daemon</var> thread. Unlike <var>[[RunAsynchronously_(Daemon_subroutine)|RunAsynchronously]]</var>, this method makes the <var>daemon</var> thread completely independent of the parent thread, so the output from the commands can never be retrieved.
RunIndependently is a member of the [[Daemon class]]
 
This method runs on the daemon thread the command or set of commands specified by its first argument. Unlike the Run method, this method returns immediately, and the thread issuing the RunIndependently method can run in parallel with the daemon thread. Unlike the [[RunAsynchronously (Daemon function)]], this method makes the daemon thread completely independent of the parent thread, so the output from the commands can never be retrieved.


==Syntax==
==Syntax==
Line 9: Line 6:
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%daem</th>
<tr><th>%daemon</th>
<td>A previously defined Daemon object. </td></tr>
<td>A previously defined <var>Daemon</var> object. </td></tr>
<tr><th>command</th>
<tr><th>string</th>
<td>A string or Stringlist that is the required command or the set of commands executed by the daemon. </td></tr>
<td>A string or Stringlist 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 daemon method object. This optional argument is passed by deep copy and not by reference, so '''%inputObj''' must be deep copyable, as described in [[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>
</table>
</table>


==Exceptions==
==Exceptions==
<var>RunIndependently</var> can throw the following exceptions:<dl>
   
   
This subroutine can throw the following exceptions:<dl>
<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.
<dt>DaemonLost  
<dd>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''' the RunIndependently method was invoked. This exception will only be thrown in ''[[Sirius Mods]]'' Version 7.2 and later.
</dl>
</dl>


==Usage notes==
==Usage notes==
<ul>
<ul><li>Issuing <var>RunIndependently</var> against a transactional <var>daemon</var> results in request cancellation.  
<li>If the <var>daemon</var> thread and its <var>daemons</var> hold record locks that conflict with the parent thread's family (excluding the <var>daemon</var> thread itself and its <var>daemons</var> ), <var>RunIndependently</var> results in request cancellation.
<li>RunIndependently was introduced in ''[[Sirius Mods]]'' Version 7.0.
<li><var>RunIndependently</var> is the rough [[Daemon_class|Daemon class]] equivalent of the <var>[[$CommBg|$commbg]]</var> function.
<li>Issuing RunIndependently against a transactional daemon results in request cancellation.  
<li>After a <var>RunIndependently</var> method, the <var>daemon</var> object is set to null. This is because the <var>daemon</var> thread runs completely independently of the parent thread once a <var>RunIndependently</var> method is invoked, so there is nothing useful the parent thread can do with such a <var>daemon</var> object, anyway.
<li>If the daemon thread and its daemons hold record locks that conflict with the parent thread's family (excluding the daemon thread and its daemons), RunIndependently results in request cancellation.  
<li>Even if the parent thread of an independently running <var>daemon</var> logs off, the <var>daemon</var> thread can continue to run.
<li>This is an example RunIndependently call:
<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><var>RunIndependently</var> was introduced in <var class="product">[[Sirius Mods|"Sirius Mods"]]</var> Version 7.0.
</ul>


<p class="code">%daem:runIndependently(%list2, %x)
==Examples==
<ol><li><p class="code">%daem:runIndependently(%list2, %x)
</p>
</p>
</ol>
<li>The RunIndependently method is the rough Daemon class equivalent of the $commbg function.
<li>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.
<li>Even if the parent thread of an independently running daemon logs off, the daemon thread can continue to run.
<li>No daemon class mechanism is provided for a parent thread to retrieve the output from an independently running daemon.
<li>As described in [[Daemon class]], RunIndependently's Stringlist argument can pass multiple commands to the daemon.
<li>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.
</ul>


==See also==
==See also==
<ul><li>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 <var>[[Run_(Daemon_function)|Run]]</var> or <var>RunIndependently</var>.</ul>
{{Template:Daemon:RunIndependently footer}}
{{Template:Daemon:RunIndependently footer}}

Revision as of 05:18, 14 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.
string 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.