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.
Return 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.
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
futureCancel a future. If the message is still queued then its removed from the actor's queue and will not be processed. No guarantee is made that the message will not be processed. See lib-task::doc#futures.
Static
futureBlock current thread until a future's result is ready. A null timeout will block forever. If an exception was raised by the asynchronous computation, then it is raised to the caller. See lib-task::doc#futures.
Static
futureReturn if a future has completed or is still pending a result. A future is completed by any of the following conditions:
Static
futureReturn current state of a future as one of the following strings:
pending
: still queued or being processedok
: completed with result valueerr
: completed with an exceptioncancelled
: future was cancelled before processing See lib-task::doc#futures.Static
futureBlock until a future transitions to a completed state (ok, err, or canceled). If timeout is null then block forever, otherwise raise a TimeoutErr if timeout elapses. Return future. See lib-task::doc#futures.
Static
futureBlock on a list of futures until they all transition to a completed state. If timeout is null block forever, otherwise raise TimeoutErr if any one of the futures does not complete before the timeout elapses. See lib-task::doc#futures.
Static
makeStatic
taskStatic
taskSet cancel flag for the given task. Cancelling a task sets an internal flag which is checked by the context's heartbeat on every Axon call. On the next Axon call the current message context will raise a sys::CancelledErr which will be raised by the respective future. Cancelling a task does not interrupt any current operations, so any blocking future or I/O calls should always use a timeout.
Static
taskReturn current task if running within the context of an asynchronous task. If context is not within a task, then return null or raise an exception based on checked flag.
Optional
checked: booleanStatic
taskIs the current context running asynchrounsly inside a task
Static
taskGet a task local variable by name or def if not defined. Must be running in a task context. See lib-task::doc#locals.
Optional
def: JsObjStatic
taskRemove a task local variable by name. Must be running in a task context. See lib-task::doc#locals.
Static
taskSet a task local variable. The name must be a valid tag name. Must be running in a task context. See lib-task::doc#locals.
Static
taskUpdate the current running task's progress data with given dict. This is a silent no-op if the current context is not running in a task.
Example:
// report progress percentage processing a list of records
recs.each((rec, index)=>do
taskProgress({percent: round(100%*index/recs.size), cur:rec.dis})
processRec(rec)
end)
taskProgress({percent:100%})
Static
taskRefresh the user account used for tasks
Static
taskRestart a task. This kills the tasks and discards any pending messages in its queue. See lib-task::doc#lifecycle.
Static
taskRun the given expression asynchronously in an ephemeral task. Return a future to track the asynchronous result. Note the expr passed cannot use any variables from the current scope. See lib-task::doc#ephemeralTasks.
Static
tasksStatic
taskAsynchronously send a message to the given task for processing. Return a future to track the asynchronous result. See lib-task::doc#messaging.
Static
taskSchedule 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 the task's queue. Return a future to track the asynchronous result. See lib-task::doc#messaging.
Static
taskSchedule 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. Return a future to track the asynchronous result. See lib-task::doc#messaging.
Static
taskSleep for the given duration. If not currently running in a task this is a no-op. This will block the current task's thread and prevent other tasks from using it until the sleep completes. So this function should be used sparingly and with care.
Task module Axon functions