lang.runtime
ballerina/lang.runtime Ballerina library
Module overview
The lang.runtime module provides functions related to the language runtime that are not specific to a particular basic type.
Functions
deregisterListener
function deregisterListener(DynamicListener 'listener)Deregisters a listener from a module.
The listener ceases to be a module listener of the module from
which this function is called.
runtime:DynamicListener ln = object { public function 'start() returns error? {} public function gracefulStop() returns error? {} public function immediateStop() returns error? {} }; runtime:deregisterListener(ln);
Parameters
- 'listener DynamicListener -
getStackTrace
function getStackTrace() returns StackFrame[]Returns a stack trace for the current call stack.
runtime:StackFrame[] stackTrace = runtime:getStackTrace();
The first member of the array represents the top of the call stack.
Return Type
- StackFrame[] - an array representing the current call stack
onGracefulStop
function onGracefulStop(StopHandler 'handler)Registers a function that will be called during graceful shutdown.
A call to onGracefulStop will result in one call to the handler function
that was passed as an argument; the handler functions will be called
after calling gracefulStop on all registered listeners,
in reverse order of the corresponding calls to onGracefulStop.
runtime:onGracefulStop(function() returns error? {});
Parameters
- 'handler StopHandler -
registerListener
function registerListener(DynamicListener 'listener)Registers a listener object with a module.
The listener becomes a module listener of the module from which this function is called.
runtime:DynamicListener ln = object { public function 'start() returns error? {} public function gracefulStop() returns error? {} public function immediateStop() returns error? {} }; runtime:registerListener(ln);
Parameters
- 'listener DynamicListener -
sleep
function sleep(decimal seconds)Halts the current strand for a predefined amount of time.
runtime:sleep(5);
Parameters
- seconds decimal - An amount of time to sleep in seconds
Object types
lang.runtime: DynamicListener
A listener that is dynamically registered with a module.
'start
function 'start() returns error?gracefulStop
function gracefulStop() returns error?immediateStop
function immediateStop() returns error?lang.runtime: StackFrame
Type representing a stack frame.
A call stack is represented as an array of stack frames. This type is also present in lang.error to avoid a dependency.
toString
function toString() returns stringReturns a string representing this StackFrame. This must not contain any newline characters.
Return Type
- string - a string
Function types
lang.runtime: StopHandler
function() returns (error?)StopHandler
Type of the function passed to onGracefulStop.