RunIndependently (Daemon subroutine): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (update syntax terms to match corrected template)
m (→‎Exceptions: remove Sirius Mods version reference)
 
(10 intermediate revisions by 4 users not shown)
Line 4: Line 4:
==Syntax==
==Syntax==
{{Template:Daemon:RunIndependently syntax}}
{{Template:Daemon:RunIndependently syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
Line 9: Line 10:
<td>A previously defined <var>Daemon</var> object. </td></tr>
<td>A previously defined <var>Daemon</var> object. </td></tr>
<tr><th>commands</th>
<tr><th>commands</th>
<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>
<td>A string or <var>[[Stringlist class|Stringlist]]</var> that is the command or the set of commands executed by the <var>daemon</var>.</td></tr>
<tr><th>inputObj</th>
<tr><th><var>Input</var></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>An object passed to the <var class="term">daemon</var> object. This optional, [[Notation conventions for methods#Named parameters|name allowed]], argument is passed by deep copy and not by reference, so <var class="term">object</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>
<var>RunIndependently</var> can throw the following exception:<dl>
   
   
<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.  
</dl>
</dl>


==Usage notes==
==Usage notes==
<ul><li>Issuing <var>RunIndependently</var> against a transactional <var>daemon</var> results in request cancellation.  
<ul>
<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>Issuing <var>RunIndependently</var> against a [[Daemon class#Transactional daemons|transactional daemon]] results in request cancellation.  
<li><var>RunIndependently</var> is the rough [[Daemon_class|Daemon class]] equivalent of the <var>[[$CommBg|$commbg]]</var> function.  
<li>If the <var class="term">daemon</var> thread and its daemons hold record locks that conflict with the parent thread's family (excluding the <var class="term">daemon</var> thread itself and its daemons), <var>RunIndependently</var> 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><var>RunIndependently</var> is the rough <var>Daemon</var> class equivalent of the <var>[[$CommBg|$CommBg]]</var> function.  
<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>After a <var>RunIndependently</var> method, the <var class="term">daemon</var> object is set to null. This is because the <var class="term">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 daemon, anyway.
<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>The passing of objects and commands to daemons is identical whether the method is <var>[[Run_(Daemon_function)|Run]]</var> or <var>RunIndependently</var> &mdash; see [[Daemon class#Working with Daemon objects|"Working with Daemon objects"]] for more information about passing commands and objects to a daemon.  
<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>Even if the parent thread of an independently running daemon logs off, the daemon thread can continue to run.  
<li><var>RunIndependently</var> was introduced in <var class="product">[[Sirius Mods|"Sirius Mods"]]</var> Version 7.0.  
<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#Working with Daemon objects|"Working with Daemon objects"]], the <var>RunIndependently</var> <var class="term">commands</var> argument can pass multiple commands to the <var class="term">daemon</var> method object.  
<li>For more information about independent daemons, see [[Daemon class#Asynchronous and Independent daemons|"Asynchronous and Independent daemons"]].
</ul>
</ul>


==Examples==
==Examples==
<ol><li><p class="code">%daem:runIndependently(%list2, %x)
<p class="code">%daem:runIndependently(%list2, %x)
</p>
</p>
</ol>


==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}}

Latest revision as of 16:33, 27 August 2018

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 command or the set of commands executed by the daemon.
Input An object passed to the daemon object. This optional, name allowed, argument is passed by deep copy and not by reference, so object must be deep copyable, as described in "Copying objects".

Exceptions

RunIndependently can throw the following exception:

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.

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, anyway.
  • The passing of objects and commands to daemons is identical whether the method is Run or RunIndependently — see "Working with Daemon objects" for more information about passing commands and objects to a daemon.
  • 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 "Working with Daemon objects", the RunIndependently commands argument can pass multiple commands to the daemon method object.
  • For more information about independent daemons, see "Asynchronous and Independent daemons".

Examples

%daem:runIndependently(%list2, %x)

See also