ReturnToMaster (Daemon subroutine): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
(Automatically generated page update)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Template:Daemon:ReturnToMaster subtitle}}
{{Template:Daemon:ReturnToMaster subtitle}}


This method returns control from a daemon thread to its master thread inside a User Language request.
This method returns control from a daemon thread to its master thread inside a <var class="product">User Language</var> request.
 
==Syntax==
==Syntax==
{{Template:Daemon:ReturnToMaster syntax}}
{{Template:Daemon:ReturnToMaster syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th nowrap="true"><var>%(Daemon)</var></th>
<tr><th><var class="nobr">%(Daemon)</var></th>
<td>The class name in parentheses denotes a shared method. <var>ReturnToMaster</var> can also be invoked via a <var>Daemon</var> object variable, which may be <var>Null</var>.</td></tr>
<td>The class name in parentheses denotes a [[Notation conventions for methods#Shared methods|shared]] method. <var>ReturnToMaster</var> can also be invoked via a <var>Daemon</var> object variable, which may be <var>Null</var>.</td></tr>
</table>
</table>
==Usage notes==
==Usage notes==
<ul>
<ul>
<li>If not issued on a daemon thread, <var>ReturnToMaster</var> results in a request cancellation.</li>
<li>If not issued on a daemon thread, <var>ReturnToMaster</var> results in a request cancellation.</li>
<li>A daemon can return objects to the master thread before invoking <var>ReturnToMaster</var> with the [[ReturnObject (Daemon subroutine)|ReturnObject]] and [[ReturnInfoObject (Daemon subroutine)|ReturnInfoObject]] methods.</li>
<li>A daemon can return objects to the master thread before invoking <var>ReturnToMaster</var> with the <var>[[ReturnObject (Daemon subroutine)|ReturnObject]]</var> and <var>[[ReturnInfoObject (Daemon subroutine)|ReturnInfoObject]]</var> methods.</li>
<li>The master thread would return control with the [[Continue (Daemon function)|Continue]], [[ContinueAsynchronously (Daemon subroutine)|ContinueAsynchronously]], or [[ContinueIndependently (Daemon subroutine)|ContinueIndependently]] method. These methods can be used to pass an object to the daemon thread.</li>
<li>The master thread would return control with the <var>[[Continue (Daemon function)|Continue]]</var>, <var>[[ContinueAsynchronously (Daemon subroutine)|ContinueAsynchronously]]</var>, or <var>[[ContinueIndependently (Daemon subroutine)|ContinueIndependently]]</var> method. These methods can be used to pass an object to the daemon thread.</li>
<li>As with the <var>Run</var> methods, a daemon thread can retrieve the object passed to it by a <var>Continue</var> method with the [[GetInputObject (Daemon subroutine)|GetInputObject]] method.
<li>As with the <var>Run</var> methods, a daemon thread can retrieve the object passed to it by a <var>Continue</var> method with the <var>[[GetInputObject (Daemon subroutine)|GetInputObject]]</var> method.
</ul>
 
==Examples==
==Examples==
 
In the following simple example of just the daemon thread code, the daemon adds numbers passed to it in an <var>XmlDoc</var> by the master thread, and it returns the result in another <var>XmlDoc</var>:
In the following silly example, a daemon thread adds numbers passed to it in an XmlDoc by the master thread and returns the result in another XmlDoc:
<p class="code">b
<p class="code">b
%doc    is object xmlDoc
%doc    is object xmlDoc
Line 28: Line 32:
   %doc:addElement('result', %result)
   %doc:addElement('result', %result)
   %(daemon):returnToMaster
   %(daemon):returnToMaster
   %(daemon):getInputObject(%doc)
   %(daemon):getInputObject(%doc)
   %nodes = %doc:selectNodes('/sum/number')
   %nodes = %doc:[[SelectNodes (XmlDoc/XmlNode function)|selectNodes]]('/sum/number')
  if %nodes:count eq 0 then loop end; end if
    if %nodes:count eq 0 then loop end; end if
   %result = 0
   %result = 0
   for %i from 1 to %nodes:count
   for %i from 1 to %nodes:count

Latest revision as of 00:59, 16 February 2014

Return control to the master thread (Daemon class)

[Introduced in Sirius Mods 8.1]


This method returns control from a daemon thread to its master thread inside a User Language request.

Syntax

%(Daemon):ReturnToMaster

Syntax terms

%(Daemon) The class name in parentheses denotes a shared method. ReturnToMaster can also be invoked via a Daemon object variable, which may be Null.

Usage notes

  • If not issued on a daemon thread, ReturnToMaster results in a request cancellation.
  • A daemon can return objects to the master thread before invoking ReturnToMaster with the ReturnObject and ReturnInfoObject methods.
  • The master thread would return control with the Continue, ContinueAsynchronously, or ContinueIndependently method. These methods can be used to pass an object to the daemon thread.
  • As with the Run methods, a daemon thread can retrieve the object passed to it by a Continue method with the GetInputObject method.

Examples

In the following simple example of just the daemon thread code, the daemon adds numbers passed to it in an XmlDoc by the master thread, and it returns the result in another XmlDoc:

b %doc is object xmlDoc %i is float %nodes is object xmlNodelist %result is float repeat forever %doc = new %doc:addElement('result', %result)  %(daemon):returnToMaster  %(daemon):getInputObject(%doc) %nodes = %doc:selectNodes('/sum/number') if %nodes:count eq 0 then loop end; end if %result = 0 for %i from 1 to %nodes:count %result = %nodes(%i):value end for end repeat end

See also