MasterNumber (Daemon property): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
(Automatically generated page update)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Template:Daemon:MasterNumber subtitle}}
{{Template:Daemon:MasterNumber subtitle}}
<var>MasterNumber</var> is a shared, ReadOnly method which returns the user number of the <b>master thread</b>, the thread that ultimately created and controls the thread from which this method is being invoked. The master thread may also be the <var>[[ParentNumber (Daemon_property)|parent thread]]</var>, the immediate creator of the thread from which this method is being invoked. However, if a parent thread also has a parent thread, the master thread is found by following the chain of parents to the ultimate level, that is, to the parent that does not itself have a parent.
<var>MasterNumber</var> is a shared, ReadOnly method which returns the user number of the <b>master thread</b>, the thread that ultimately created and controls the thread from which this method is being invoked. The master thread may also be the [[ParentNumber (Daemon_property)|parent thread]], the immediate creator of the thread from which this method is being invoked. However, if a parent thread also has a parent thread, the master thread is found by following the chain of parents to the ultimate level, that is, to the parent that does not itself have a parent.
<p>To return the user number of only the immediate parent thread, you can use <var>[[ParentNumber (Daemon_property)|ParentNumber]]</var>. Where a parent thread exists but has no parent itself, <var>MasterNumber</var> returns the same value as <var>ParentNumber</var>.</p>
<p>
<p>If the thread issuing the <var>MasterNumber</var> method is not an sdaemon, or is an sdaemon but not working for a <var>[[Daemon class|Daemon]]</var> object or a <var>[[List of $functions|"$COMMxx function"]]</var>, or is an independent <var>daemon</var> (started with <var>[[$CommBg|$commbg]]</var> or <var>[[RunIndependently (Daemon subroutine)|RunIndependently]]</var> under <var class="product">[[Sirius Mods]]</var> 7.0 or later), the <var>MasterNumber</var> property returns a value of <code>-1</code>.</p>
To return the user number of only the immediate parent thread, you can use <var>[[ParentNumber (Daemon_property)|ParentNumber]]</var>. Where a parent thread exists but has no parent itself, <var>MasterNumber</var> returns the same value as <var>ParentNumber</var>.</p>
<p>
If the thread issuing the <var>MasterNumber</var> method is not an sdaemon, or is an sdaemon but not working for a <var>Daemon</var> object or a [[List of $functions|"$COMMxx function"]], or is an independent <var>daemon</var> (started with <var>[[$CommBg|$commbg]]</var> or <var>[[RunIndependently (Daemon subroutine)|RunIndependently]]</var> under <var class="product">[[Sirius Mods]]</var> 7.0 or later), the <var>MasterNumber</var> property returns a value of <code>-1</code>.</p>
   
   
==Syntax==
==Syntax==
Line 10: Line 12:
<tr><th>%number</th>
<tr><th>%number</th>
<td>A numeric variable to contain the value of the user number of the master thread. </td></tr>
<td>A numeric variable to contain the value of the user number of the master thread. </td></tr>
<tr><th><var>%(Daemon)</var></th>
<tr><th><var class="nobr">%(Daemon)</var></th>
<td>The class name in parentheses denotes a [[Notation conventions for methods#Shared methods and constructors|shared]] method. <var>MasterNumber</var> can also be invoked via a <var>Daemon</var> object variable, which may be null.</td></tr>
<td>The class name in parentheses denotes a [[Notation conventions for methods#Shared methods|shared]] method. <var>MasterNumber</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>The <var>MasterNumber</var> method has a <var>[[List of $functions|$function]]</var> equivalent: <var>[[$DaemonMasterNumber|$daemonMasterNumber]]</var>. The $function and method can be used interchangeably, whether the <var>daemons</var> were created with $<var>$COMMxx</var> functions or <var>[[Daemon class|Daemon]]</var> objects. That is, the method can also be used with <var>daemons</var> that were created via $<var>$COMMxx</var>, and the $function can also be used with daemons that were created via <var>Daemon</var>objects.
<li>The <var>MasterNumber</var> method has a [[List of $functions|$function]] equivalent: <var>[[$DaemonMasterNumber]]</var>. The $function and method can be used interchangeably, whether the daemons were created with $COMMxx functions or <var>Daemon</var> objects. That is, the method can also be used with daemons that were created via $COMMxx, and the $function can also be used with daemons that were created via <var>Daemon</var> objects.
 
<li>An asynchronous <var>$COMMBG</var> daemon or an independent daemon started with <var>[[RunIndependently (Daemon subroutine)|RunIndependently]]</var> might have a parent thread but never a master thread; master implies control.
<li>An asynchronous <var>$COMMBG</var> daemon or an independent daemon started with <var>[[RunIndependently (Daemon subroutine)|RunIndependently]]</var> might have a parent thread but never a master thread; master implies control.
<li><var>[[ParentNumber (Daemon property)|ParentNumber]]</var> returns the user number of the parent thread, the thread that created the current thread from which this method is being invoked.
And <var>[[UserNumber (Daemon property)|UserNumber]]</var> returns the user number of the thread associated with the daemon method object.
</ul>
</ul>
   
   
==Examples==
==Examples==
<ol><li>The following code audits a thread's master user number:
<ol>
<li>The following code audits a thread's master user number:
<p class="code"><nowiki>audit 'My master''s user number is ' %(daemon):masterNumber
<p class="code"><nowiki>audit 'My master''s user number is ' %(daemon):masterNumber
</nowiki></p>
</nowiki></p>
Line 27: Line 34:


==See also==
==See also==
<ul>
<li><var>[[ParentNumber (Daemon property)|ParentNumber]]</var>, which returns the user number of the parent thread, the thread that created the current thread from which this method is being invoked.
<li><var>[[UserNumber (Daemon property)|UserNumber]]</var>, which returns the user number of the thread associated with the daemon method object.
</ul>
{{Template:Daemon:MasterNumber footer}}
{{Template:Daemon:MasterNumber footer}}

Latest revision as of 00:57, 16 February 2014

User number of the master thread (Daemon class)

MasterNumber is a shared, ReadOnly method which returns the user number of the master thread, the thread that ultimately created and controls the thread from which this method is being invoked. The master thread may also be the parent thread, the immediate creator of the thread from which this method is being invoked. However, if a parent thread also has a parent thread, the master thread is found by following the chain of parents to the ultimate level, that is, to the parent that does not itself have a parent.

To return the user number of only the immediate parent thread, you can use ParentNumber. Where a parent thread exists but has no parent itself, MasterNumber returns the same value as ParentNumber.

If the thread issuing the MasterNumber method is not an sdaemon, or is an sdaemon but not working for a Daemon object or a "$COMMxx function", or is an independent daemon (started with $commbg or RunIndependently under Sirius Mods 7.0 or later), the MasterNumber property returns a value of -1.

Syntax

%number = %(Daemon):MasterNumber

Syntax terms

%number A numeric variable to contain the value of the user number of the master thread.
%(Daemon) The class name in parentheses denotes a shared method. MasterNumber can also be invoked via a Daemon object variable, which may be Null.

Usage notes

  • The MasterNumber method has a $function equivalent: $DaemonMasterNumber. The $function and method can be used interchangeably, whether the daemons were created with $COMMxx functions or Daemon objects. That is, the method can also be used with daemons that were created via $COMMxx, and the $function can also be used with daemons that were created via Daemon objects.
  • An asynchronous $COMMBG daemon or an independent daemon started with RunIndependently might have a parent thread but never a master thread; master implies control.
  • ParentNumber returns the user number of the parent thread, the thread that created the current thread from which this method is being invoked. And UserNumber returns the user number of the thread associated with the daemon method object.

Examples

  1. The following code audits a thread's master user number:

    audit 'My master''s user number is ' %(daemon):masterNumber

  2. See the "ParentNumber property example".

See also