rayaman / multi

My multitasking library for lua
MIT License
27 stars 0 forks source link

Add SystemThreadedProcessor #50

Closed rayaman closed 1 year ago

rayaman commented 1 year ago

A system threaded processor that will try to schedule your processes throughout various nodes.

Ideas:

rayaman commented 1 year ago

In progress, you are able to spawn objects in another thread and interact with them loosely using proxy objects!

package.path = "?/init.lua;?.lua;"..package.path

multi, thread = require("multi"):init({print=true})
THREAD, GLOBAL = require("multi.integration.lanesManager"):init()

stp = multi:newSystemThreadedProcessor("Test STP")

alarm = stp:newAlarm(3)

alarm.OnRing:Connect(function(alarm)
    print("Hmm...", THREAD_NAME)
end)

Output:

Hmm...  SystemThreadedJobQueue_A5tp

This event is subscribed to on the proxy threads side of things!

Currently supporting:

If you would like to connect to a "STP Connection" object you can do so in a STP Function using hold and connect to the function OnReturn event or have the function wait (When in a coroutine it will only pause execution for that coroutine(multi:newThread(...))). The function is still runs on the Thread that the STP is running on. There is no guarantee that the function will run on the same thread each time, unlike with the multi objects/cothreads. Those stay on the systhread they are created on.

rayaman commented 1 year ago

Mostly done, currently working on proxy objects

rayaman commented 1 year ago

Proxy objects are now done! This is done