RunIndependently (Daemon subroutine)

From m204wiki
Revision as of 20:01, 31 December 2010 by Dme (talk | contribs)
Jump to navigation Jump to search

Run specified command(s) in parallel with issuing thread.

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.

RunIndependently Syntax

%daem:RunIndependently(command, [%inputObj])

Syntax Terms

%daem
A previously defined Daemon object.
command
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 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.

Exceptions

This subroutine 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 the RunIndependently method was invoked. This exception will only be thrown in Sirius Mods Version 7.2 and later.

Usage Notes

  • RunIndependently was introduced in Sirius Mods Version 7.0.
  • 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 and its daemons), RunIndependently results in request cancellation.
  • This is an example RunIndependently call:
    %daem:runIndependently(%list2, %x)
    
  • The RunIndependently method 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 Stringlist argument can pass multiple commands to the daemon.
  • 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.