New (Daemon constructor)

From m204wiki
Jump to navigation Jump to search

Create a new Daemon (Daemon class)


%daemon = [%(Daemon):]New[( [CopyGlobals= boolean], [Transactional= boolean], - [OpenAll= boolean])] Throws MaxDaemExceeded, NoFreeDaemons, DaemonLost

Syntax terms

%daemon A Daemon object.
[%(Daemon):] The optional class name in parentheses denotes a Constructor. See Usage notes, below, for more information about invoking a Daemon Constructor.
CopyGlobals An optional, name required parameter whose value is a Boolean enumeration.

The default is False: do not copy the existing global variable information from the master thread; use default GTBL-creation settings for the daemon. If set to True:

  • The GTBL server table is set to the same size on the daemon as it is on the master thread.
  • The GTBLHASH and GTBLPCT parameters on the daemon thread are set to the same values as on the master thread.
  • Only unstructured globals (globals created by $Setg or $Getg) and permanent global Images in the master thread GTBL are copied to the daemon (global foundsets/lists, global Screens, and any temporary global items are not copied).
Transactional An optional, name required, parameter whose value is a Boolean enumeration.
  • If set to True, the daemon is transactional, with the master and daemon threads share a single updating transaction.
  • If set to False, the default, the daemon is non-transactional.
OpenAll An optional, name required, parameter whose value is a Boolean enumeration. If set to True, the daemon thread opens all files and groups that are open on the master thread. The files and groups are opened with the same privileges as on the master thread. Any temporary groups open on the master thread are also recreated on the Daemon thread and then opened.

This parameter is new as of Sirius Mods Version 8.1.


This subroutine can throw the following exception:

NoFreeDaemons If there are no daemon threads available to service the object, a NoFreeDaemons exception is thrown.

Usage notes

  • As described in Using New or other Constructors, New can be invoked with no object, with an explicit class name, or with an object variable in the class, even if that object is Null:

    %daemon = new %daemon = %(Daemon):new %daemon = %daemon:new

  • New not only creates a Daemon object in the user tables, but it also finds a free sdaemon thread and dedicates it to the issuing user. If no sdaemon threads are available, the request is cancelled.
  • The number of daemons allowed per master thread is limited by the MAXDAEM system parameter, whose default value is 1.
  • If you specify CopyGlobals=True, and if there is insufficient server space (say, if daemons start out with very big tables, except for GTBL, and the master has a very big GTBL), the daemon fails during initialization.
  • Even files opened as part of the subsystem being run by the master thread are opened on a daemon thread when OpenAll=True is specified.
  • Opening a lot of files via OpenAll=True is more efficient than opening the files individually with the Open method.
  • If LFTBL on the daemon thread is not enough to allow opening all the groups to be opened by OpenAll=True, the daemon thread issues an error message and logs off, and the New method fails.
  • If you want to use the master thread's open temp groups on the daemon thread, using OpenAll keeps you from having to recreate the temp groups on the Daemon thread.

See also