Do we put parrellel scipt in the Actor?

do we put parrellel scipt in the Actor?

If you want to make use of multi-threading, the script itself goes inside an actor.

This does not make the script multi-threaded but it allows you to make use of ScriptSignal:ConnectParallel() and task.desynchronize() and such.

When you use task.desynchronize() in a script, all code that runs after it becomes multi-threaded until you call task.synchronize().

Read about it here.

ok

1 Like

but why dont use coroutine???66

Coroutines does not run code in parallel, they still use a single cpu thread, but it allows for different “code threads” to run asyncronously

I was playing with luasocket, a library (outside of Roblox) to make http requests, and with that library, calls are blocking, even with coroutines, it blocks everything until it is done. The functions do not call coroutine.yeild() (or whatever, the library is mostly coded in C), so it never allows other code to run

To put it more specifically.

If you have any functions that yield or you’re using task.wait(), you can use coroutines to run some extra code right next to it that is not paused by the yield or wait().

It doesn’t create a new thread on a different CPU core.

It simply let’s you do “multi-tasking” on the same CPU core inside the same script but prevents yielding functions and task.wait()s from pausing the extra tasks.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.