Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ProcessSystem

Manages all of the processes.

Hierarchy

  • ProcessSystem

Index

Constructors

constructor

Properties

current_process

current_process: Process | null

links

links: Map<PID, Set<PID>>

mailboxes

mailboxes: Map<PID, Mailbox>

main_process_pid

main_process_pid: PID

monitors

monitors: Map<Reference, object>

names

names: Map<any, PID>

pids

pids: Map<PID, Process>

scheduler

scheduler: DefaultScheduler

suspended

suspended: Map<PID, function>

Accessors

Private currentProcess

  • get currentProcess(): Process | null

Methods

add_proc

  • add_proc(fun: GeneratorFunction, args: any[], linked: boolean, monitored: boolean): Process

delay

  • delay(fun: function, time: number): void

demonitor

  • demonitor(ref: Reference): Boolean

erase

  • erase(key?: undefined | string): void
  • Removes the key and the associated value from the current process's dictionary

    If no key is given, removes all entries from the current process's dictionary

    Parameters

    • Optional key: undefined | string

      the key to remove

    Returns void

error

  • error(reason: any): void

exit

  • exit(one: PID | any, two?: any): void
  • terminates the current process with the given reason.

    Parameters

    • one: PID | any
    • Optional two: any

    Returns void

get

  • get(key: string, default_value?: any): any
  • Gets a value from the current process's dictionary or the default if key not in dictionary

    Parameters

    • key: string
    • Default value default_value: any = null

    Returns any

get_keys

  • get_keys(value: any): string[]

get_process_dict

  • get_process_dict(): object

is_alive

  • is_alive(pid: any): boolean

link

  • link(pid: PID): void
  • links the current process with the process from the given pid

    Parameters

    • pid: PID

      pid of the process to link to

    Returns void

list

  • list(): PID[]

make_ref

  • make_ref(): Reference

monitor

  • monitor(pid: PID): Reference | null

pid

  • pid(): PID | null

pidof

  • pidof(id: PID | any): PID | null
  • takes the input and tries to find the pid. Input can be a pid, Process, or name the pid is associated with

    Parameters

    • id: PID | any

      The registered name or pid of the process

    Returns PID | null

process_flag

  • process_flag(...args: any[]): any
  • Sets flags on the current process.

    • Note: the only flag respected is the Symbol.for("trap_exit") flag. If value is true, then exit signals from linked processes are turned into messages and sent to the current processes mailbox. If value is false, the exit is treated as normal and terminates the process. Setting it to true is useful for supervising processes.

    Parameters

    • Rest ...args: any[]

    Returns any

put

  • put(key: string, value: any): void

receive

  • receive(fun: Function, timeout?: number, timeoutFn?: function): (null | number | symbol | Function)[]
  • Tells the current process to receive a message that the function can handle. If no match then the process is put in the suspended state until a message arrives or the timeout is reached. If the timeout is reached and no msg matches, then the timeoutFn is called

    Parameters

    • fun: Function
    • Default value timeout: number = 0
    • Default value timeoutFn: function = () => true
        • (): boolean
        • Returns boolean

    Returns (null | number | symbol | Function)[]

register

  • register(name: any, pid: PID): void
  • registers the given name to the pid

    Parameters

    • name: any

      The name to give the process

    • pid: PID

      The pid of the process

    Returns void

registered

  • registered(): IterableIterator<any>

remove_proc

  • remove_proc(pid: PID, exitreason: any): void

schedule

  • schedule(fun: function, pid?: PID): void
  • Schedules execution of a process reduction

    Parameters

    • fun: function
        • (): any
        • Returns any

    • Optional pid: PID

    Returns void

send

  • send(id: any, msg: any): any

set_current

  • set_current(id: PID | any): void

sleep

  • sleep(duration: number | symbol): [symbol, number | symbol]

spawn

  • spawn(...args: any[]): PID
  • Starts a process represented by the given generator function

    Parameters

    • Rest ...args: any[]

      Either a generator function or a module, function and arguments

    Returns PID

spawn_link

  • spawn_link(...args: any[]): PID
  • Starts a process using the generator function from the specified module

    Parameters

    • Rest ...args: any[]

      Either a generator function or a module, function and arguments

    Returns PID

spawn_monitor

  • spawn_monitor(...args: any[]): [PID, Reference]
  • Spawns a process and then monitors it

    Parameters

    • Rest ...args: any[]

      Either a generator function or a module, function and arguments

    Returns [PID, Reference]

suspend

  • suspend(fun: function): void

unlink

  • unlink(pid: PID): void
  • unlinks the current process from the process from the given pid

    Parameters

    • pid: PID

      pid of the process to link to

    Returns void

unregister

  • unregister(pid: PID): void

whereis

  • whereis(name: any): any | null

Static run

  • run(fun: Function, args: any[], context?: any): IterableIterator<any>

Generated using TypeDoc