How exactley would Multithreading work in S&Box?

I have written an application in Unity that has the simple task of constantly executing a mathematical calculation and, after each completion of this calculation, specifying the time used in “ms”.
Unity has a relatively modern “job system” that takes care of the efficient distribution of tasks. But how exactly will it work in S & Box if you want to distribute a intensive task over several cores in an addon?

Personally, I would like to find out about it as early as possible in order to make a move for S & Box, whose train carriage run on additional cores as far as technically possible.

1 Like

This question can be asked for both client and server, I will try to search a bit after work.

1 Like

You can use Tasks, which are already used by the gamemodes they have published.
Yes, tasks are not exactly multi threading but will likely solve your issue. S&box or .NET will handle how your tasks are distributed

I would like to build a train add-on where you can attach as many railway cars as possible to each other and where my script uses the full potential of the available hardware!
My goal is when a player spawns another railway car, each car looks for a CPU core that is most unused as possible and then creates a thread for its own tasks there.

Would that work with what you propose to me here?

Tasks would handle that perfectly. Do note that you generally cannot access anything gameplay related outside of the main thread though.

1 Like

Most games typically use one core only.
Would S&Box use more than one core?

Please see here, I already posted a bunch of links (linked to some other bunches of links … linkception) where you can understand how multicore can be used on S&Box: Databases? - #6 by Kyominii

1 Like