<Default Package>
Type context


A reference to a context.

A context reference can be used to spawn monitor instances or send events to the referenced contexts. You cannot create a context reference which points to an existing context, you can only be passed a reference from whoever created the context.

The channels to which a context is subscribed are not available from a context reference.

To create a new context, construct an instance of a context and then spawn an action to it. The constructor of a context takes a string name, which is purely for logging purposes and does not need to be unique. In addition, it can optionally take a boolean parameter to indicate whether the context is public or not.
context(string name, boolean receivesInput=false);
By default, contexts are not public. A public context receives all events sent to the default channel. All non-public contexts will only receive events on channels to which a monitor instance explicitly subscribes.

Events can be sent to a context with:
send Event() to ctx;
Code can be spawned to a context with:
spawn action() to ctx;
Attempting to send or spawn to a default-initialized context reference will throw an exception.

Contexts cannot be parsed. They can be routed internally, but cannot be received on an input queue. They are comparable and are acyclic.
See Also:
monitor#subscribe() - To subscribe a context to a channel.
monitor#unsubscribe() - To unsubscribe a context from a channel.

Action summary
 contextstatic current()

Get a context object that is a reference to the current context.
 integergetId()

Get the unique identifier of this context.
 stringgetName()

Get the name of this context.
 integerhash()

Get an integer hash representation of the underlying object.
 integeriqSize()

Get the size of the input queue.
 booleanisPublic()

Check whether the context is public.
 stringtoString()

Convert this context to a string.
 
Action detail

current

            context static current()
        
Get a context object that is a reference to the current context.

The current context is the context that contains the monitor instance or event instance that is calling this method.
Returns:
The current context.

getId

            integer getId()
        
Get the unique identifier of this context.
Returns:
The identifier of this context.

getName

            string getName()
        
Get the name of this context.

This is the string that was specified when the context was created. The main context that onload() methods run in is called "main".
Returns:
The name of this context.

hash

            integer hash()
        
Get an integer hash representation of the underlying object.

This function will return an integer evenly distributed over the whole range suitable for partitioning or indexing of that structure. Multiple different object can resolve to the same hash value.
Returns:
An integer respresentation of the underlying object.

iqSize

            integer iqSize()
        
Get the size of the input queue.
Returns:
The number of items on the input queue of this context.

isPublic

            boolean isPublic()
        
Check whether the context is public.
Returns:
True if this context receives events on the default channel, false otherwise.

toString

            string toString()
        
Convert this context to a string.

The string form of a context is "context(" id "," name "," public ")", where id is an integer, name is a quoted string, and public is true if the context is public or is false if the context is private.

Contexts cannot be parsed.
Returns:
The string form of this context.