MasterNumber (Daemon property): Difference between revisions
m (1 revision) |
m (1 revision) |
||
Line 14: | Line 14: | ||
{{Template:Daemon:MasterNumber syntax}} | {{Template:Daemon:MasterNumber syntax}} | ||
===Syntax terms=== | ===Syntax terms=== | ||
< | <table class="syntaxTable"> | ||
< | <tr><th><i>%num</i></th> | ||
< | <td>A numeric variable to contain the value of the user number of the master thread. </td></tr> | ||
< | <tr><th>%(Daemon)</th> | ||
< | <td>The class name in parentheses denotes a shared method. Specifying <tt>%(Daemon):</tt> is not the only way to invoke the method (see [[Daemon class]]).</td></tr> | ||
</table> | |||
==Usage notes== | ==Usage notes== |
Revision as of 04:53, 7 February 2011
User number of the master thread (Daemon class)
MasterNumber is a member of the Daemon class
This shared, ReadOnly method 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 the ParentNumber method (:hdref refid=daempnm.). 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.
MasterNumber, new as of &SIRMODS. &vsn. 6.8, takes no arguments and returns a numeric value.
Syntax
%number = %(Daemon):MasterNumber
Syntax terms
%num | 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. Specifying %(Daemon): is not the only way to invoke the method (see Daemon class). |
Usage notes
- The following code audits a thread's master user number:
audit 'My master''s user number is ' %(daemon):masterNumber
- 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 start with the RunIndependently method might have a parent thread but never a master thread; master implies control.
Example
See the ParentNumber property example in ParentNumber (Daemon property).
See also
- The UserNumber (Daemon property) returns the user number of the thread associated with the daemon method object.