Multi-threading


#1

I’m not sure to understand how multi-threading works :confused:
1 - The function CreateWorkers() need a count. In the doc I read: “The number of worker thread is usually equal to the number of HW threads the host processor supports”
Is there a way to get the number of HW thread of the computer ?

2 - …I d’ont understand how to create a new task…Perhaps you can add an sample of Python program that create threads ?


#2

Hi !

This might be a bit out of topic, but if you need to perform a task outside Python and get it done by a Lua VM, you might use a logic script.

Basically, you will need to set a logic script (in Lua) to an existing node, and get all your stuff done from there.

It works like this :

cube = plus.AddCube(scn, gs.Matrix4.Identity, 5) cube.AddComponent(gs.LogicScript("@data/spin_and_sleep.lua"))

You have an example here :

and the Lua logic script here :

/!\ This is not a direct use of workers, but Harfang will still balance the CPU load in a smart way.


#3

There is a second approach to this, the Lua Task System.
You will find the information you need here :


#4

Thanx ! That will help me.