Return a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object:
this < that => <0
this == that => 0
this > that => >0
This method may also be accessed via the <
<=
<=>
>=
and >
shortcut operators. If not overridden the default
implementation compares the toStr
representations. Also see docLang.
Examples:
3.compare(8) => -1
8.compare(3) => 1
8.compare(8) => 0
3 <=> 8 => -1 // shortcut for 3.compare(8)
Compare this object to the specified for equality. This
method may be accessed via the == and != shortcut operators.
If not overridden the default implementation compares for
reference equality using the === operator. If this method
is overridden, then hash() must also be overridden such that
any two objects which return true for equals() must return
the same value for hash(). This method must accept null
and
return false.
Lookup a observable for the runtime by name.
Optional
checked: booleanReturn a unique hashcode for this object. If a class overrides hash() then it must ensure if equals() returns true for any two objects then they have same hash code.
List the published observables for the runtime
The pool used to control execution of this actor.
Asynchronously send a message to this actor for processing. If msg is not immutable, then NotImmutableErr is thrown. Throw Err if this actor's pool has been stopped. Return a future which may be used to obtain the result once it the actor has processed the message. If the message is coalesced then this method returns the original message's future reference. Also see sendLater and sendWhenComplete.
Schedule a message for delivery after the specified period of duration has elapsed. Once the period has elapsed the message is appended to the end of this actor's queue. Accuracy of scheduling is dependent on thread coordination and pending messages in the queue. Scheduled messages are not guaranteed to be processed if the actor's pool is stopped. Scheduled messages are never coalesced. Also see send and sendWhenComplete.
Schedule a message for delivery after the given future has completed. Completion may be due to the future returning a result, throwing an exception, or cancellation. Send-when-complete messages are never coalesced. The given future must be an actor based future. Also see send and sendLater.
Get an immutable representation of this instance or throw NotImmutableErr if this object cannot be represented as an immutable:
Return a string representation of this object.
Trap a dynamic call for handling. Dynamic calls are invoked with the -> shortcut operator:
a->x a.trap("x", null)
a->x() a.trap("x", null)
a->x = b a.trap("x", [b])
a->x(b) a.trap("x", [b])
a->x(b, c) a.trap("x", [b, c])
The default implementation provided by Obj attempts to use reflection. If name maps to a method, it is invoked with the specified arguments. If name maps to a field and args.size is zero, get the field. If name maps to a field and args.size is one, set the field and return args[0]. Otherwise throw UnknownSlotErr.
This method called whenever an it-block is applied to an
object. The default implementation calls the function with this
,
and then returns this
.
Static
echoWrite x.toStr
to standard output followed by newline. If x
is null then print "null". If no argument is provided then
print an empty line.
Optional
x: JsObjStatic
localsStatic
makeCreate an actor whose execution is controlled by the given ActorPool. If receive is non-null, then it is used to process messages sent to this actor. If receive is specified then it must be an immutable function (it cannot capture state from the calling thread), otherwise NotImmutableErr is thrown. If receive is null, then you must subclass Actor and override the receive method.
Static
makeCreate an actor with a coalescing message loop. This constructor follows the same semantics as make, but has the ability to coalesce the messages pending in the thread's message queue. Coalesced messages are merged into a single pending message with a shared Future.
The toKey
function is used to derive a key for each message,
or if null then the message itself is used as the key. If
the toKey
function returns null, then the message is not
considered for coalescing. Internally messages are indexed
by key for efficient coalescing.
If an incoming message has the same key as a pending message
in the queue, then the coalesce
function is called to
coalesce the messages into a new merged message. If coalesce
function itself is null, then we use the incoming message
(last one wins). The coalesced message occupies the same
position in the queue as the original and reuses the
original message's Future instance.
Both the toKey
and coalesce
functions are called while
holding an internal lock on the queue. So the functions
must be efficient and never attempt to interact with other
actors.
Static
sleepPut the currently executing actor thread to sleep for the specified period. If the thread is interrupted for any reason while sleeping, then InterruptedErr is thrown.
Observable APIs