usage: require("process")
this library is primarily intended for creating operating systems
it doesn't implement multithreading or anything like that, it implements sandbox creation mechanisms for running SComputers scripts
it implements support for callbacks such as callback_loop, callback_error and newer ones onTick, OnStart, onStop, onError
and if the new entry point (callback_loop/onTick) is not declared, then the entire program will be a loop, as it was in the original ScriptableComputer
in this library, you also need to use the _enableCallbacks flag to include new callbacks in place of the old ones
note that some functions refer to each other inside the ENV. for example, if you redefine getComponents, it will automatically change the behavior of all obsolete methods such as getDisplays, getPorts, etc. if you redefine setData/getData, it will automatically redefine setTable/getTable
more information about the work of callbacks is described here: environment
note that if you create a chain of nested processes, then at each level below processlibrary.createEnv in the library, the process will be redefined so that first call the createEnv user function at a higher level
thus, if you have several nested processes each using createEnv, then when creating an ENV, the entire createEnv chain will be called up to the top level to apply all modifications to the ENV

methods:

processhost methods:

process methods:

            local processlibrary = require("process")
local processhost = processlibrary.createHost()

local code = [[print("init", getTick())

function onStart()
    print("start", getTick())
end

function onTick()
    print("tick", getTick())
    if getTick() > 40 then
        error("test")
    end
end

function onStop()
    print("stop", getTick())
end

function onError(err)
    print("err", err, getTick())
end

_enableCallbacks = true]]

local process = processhost:create(function()
    local env = processlibrary.createEnv()
    env.print = logPrint
    env.logPrint = logPrint
    env.alert = logPrint
    env.warning = logPrint
    env.log = logPrint
    return env
end)
process:load(code, "=VM")

function onTick()
    processhost:tick()
    local error = process:getError()
    if error then
        logPrint("process error: ", error)
        process:reboot()
    end
end

function onStop()
    processhost:stop()
end

_enableCallbacks = true
        
            local processlibrary = require("process")
local processhost = processlibrary.createHost()

local code = [[print("init", getTick())

function onStart()
    print("start", getTick())
end

function onTick()
    print("tick", getTick())
    if getTick() > 40 then
        error("test")
    end
end

function onStop()
    print("stop", getTick())
end

function onError(err)
    print("err", err, getTick())
    return true --calling a software reboot in case of an error
end

_enableCallbacks = true]]

local process = processhost:create(function()
    local env = processlibrary.createEnv()
    env.print = logPrint
    env.logPrint = logPrint
    env.alert = logPrint
    env.warning = logPrint
    env.log = logPrint
    return env
end)
process:load(code, "=VM")

function onTick()
    processhost:tick()
    local error = process:getError()
    if error then
        logPrint("process error: ", error) --in this example, this line of code will never work because it triggers a software reboot from the script itself in case of an error
    end
end

function onStop()
    processhost:stop()
end

_enableCallbacks = true