ParentNumber (Daemon property)
User number of the parent thread (Daemon class)
ParentNumber returns the user number of the parent thread, the thread that created the thread from which this method is being invoked.
If the thread issuing the ParentNumber method is not an sdaemon, or is an sdaemon but not working for a Daemon object or a $COMMxx function, the ParentNumber property returns a value of
%number = %(Daemon):ParentNumber
|%number||A numeric variable to contain the value of the number of the parent thread.|
|%(Daemon)||The class name in parentheses denotes a shared method. ParentNumber can also be invoked via a Daemon object variable, which may be Null.|
- MasterNumber returns the user number of the master thread, the thread that ultimately created and controls the thread from which this method is being invoked.
UserNumber returns the user number of the thread associated with the daemon method object.
MasterNumber returns the same value as the ParentNumber method if the parent thread has no parent. Otherwise, MasterNumber method follows the parent chain to the highest level, that is, to the parent that does not have a parent.
- 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.
- ParentNumber has a $function equivalent: $DaemonParentNumber. 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 functions, and the $function can also be used with daemons that were created via Daemon objects.
- The following code audits a thread's parent user number:
audit 'My parent''s user number is ' %(daemon):parentNumber
- In the following example, a daemon runs a request that creates another daemon. ParentNumber, issued on the first daemon thread, returns the user number of the thread that created the first daemon: the user that runs the request.
begin %speed is object daemon %list is object stringList %s is object stringList %speed = new %n is float %n = %speed:usernumber print '1st daemon user number is: ' %n %list = new text to %list begin %n1 is float %n2 is float %n3 is float %speed2 is object daemon %speed2 = new %n1 = %speed2:usernumber %n2 = %(Daemon):masternumber %n3 = %(Daemon):parentnumber print %n1 print %n2 print %n3 end end text %x = new %x = %speed:run(%list) print '2nd daemon usernum, 1st daemon master and parent are: ' %x:print end
The example result follows:
1st daemon user number is: 3 2nd daemon user num, 1st daemon master and parent are: 5 18 18