@r47onfire/backolon - v0.0.0
    Preparing search index...

    Class Scheduler

    Backolon task scheduler responsible for running code and native functions.

    Index

    Constructors

    • Parameters

      • builtins: [NativeModule, ...NativeModule[]]

        List of builtin modules available to tasks run by this scheduler. Each module's environment (native functions, patterns, variables) will be included in the search path for new tasks.

      • OptionalprintHook: (x: string) => void

        Called with a string whenever a task calls the Backolon print function. Can be used to capture printed output in a custom environment (e.g. a web REPL).

      • customNames: Record<string, new (...args: any[]) => any> = {}

        Names of special classes to preserve when serializing the scheduler's state with serializeTasks and loadFromSerialized. See the Resurrect.js library documentation for details.

      Returns Scheduler

    Properties

    builtins: [NativeModule, ...NativeModule[]]

    List of builtin modules available to tasks run by this scheduler. Each module's environment (native functions, patterns, variables) will be included in the search path for new tasks.

    printHook?: (x: string) => void

    Called with a string whenever a task calls the Backolon print function. Can be used to capture printed output in a custom environment (e.g. a web REPL).

    recursionLimit: number = 1000

    Maximum allowed stack length before a task throws a recursion error. Backolon uses its own stack and not the JavaScript call stack, so this serves to prevent out-of-memory errors.

    tasks: Task[] = []

    List of currently active tasks, sorted by priority (lowest first). Tasks that have finished executing but haven't been removed from the list yet will have an empty stack.

    Methods

    • Parameters

      Returns CustomApplicator | null

    • Deserializes a string produced by serializeTasks and adds the resulting tasks to the scheduler. Note that the deserialized tasks will share the same Scheduler instance (this) as each other and any tasks that were already in the scheduler, but will not share any state with tasks that were already in the scheduler before (e.g. they won't share environments or variables).

      Parameters

      • str: string

      Returns void

    • Dumps the state of all tasks into a string, which can later be loaded with loadFromSerialized to restore the tasks and their states.

      Returns string

    • Start a new task with the given code and environment. The code can be provided as a string (in which case it will be parsed) or as a pre-parsed Thing. The environment is a list of env Things, which will be searched in order when looking up variables; if null or omitted, the environments of all builtin modules will be used.

      The new Task will have its top-level block in a new environment that has the provided envs as parents, so changes to the top-level block's environment won't affect the provided envs or other tasks that share those envs.

      Parameters

      • priority: number
      • code: string
      • envs: (Thing<env> | Thing<nil>)[] | null
      • filename: URL

      Returns Task

    • Start a new task with the given code and environment. The code can be provided as a string (in which case it will be parsed) or as a pre-parsed Thing. The environment is a list of env Things, which will be searched in order when looking up variables; if null or omitted, the environments of all builtin modules will be used.

      The new Task will have its top-level block in a new environment that has the provided envs as parents, so changes to the top-level block's environment won't affect the provided envs or other tasks that share those envs.

      Parameters

      Returns Task

    • Run tasks until all tasks are suspended or complete or the optional maxSteps limit is reached (-1 or undefined means no limit). Returns true if any progress was made (i.e. any task executed at least one step).

      Parameters

      • maxSteps: number = -1

      Returns boolean