RunIndependently (Daemon subroutine): Difference between revisions
Jump to navigation
Jump to search
m (→Usage notes) |
m (→Exceptions: remove Sirius Mods version reference) |
||
(One intermediate revision by one other user not shown) | |||
Line 16: | Line 16: | ||
==Exceptions== | ==Exceptions== | ||
<var>RunIndependently</var> can throw the following | <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 | <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> | ||
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)