Threads in LC
bobsneidar at iotecdigital.com
Thu Jan 7 20:51:42 EST 2021
I have thought about this a bit. If what you mean by multiprocessing is that a new process can be spawned while your app can go off and do other things and get notified later that something happened, then this is quite doable. If what you mean is that you want to make the app spawning the processes operate more efficiently by launching the same process over and over in multiple instances, then I don’t think so. At some point the parent process is going to have to get the result of each thread and do something about it.
This assumes you NEED to hear back from the process. If that is not necessary, if you have a really good chance that nothing can go wrong, then I suppose it can be something along the lines of network multicasting where the packets go out into the ether, and they are on their own.
The real advantage to setting up a pseudo multiprocessing system with LC is that your main process can go about it’s business while the child process is doing some heavy lifting. If the main process cannot continue, or continue very far without hearing back from the spawn, then the point is moot.
For example, I can see a scenario where an agent could listen for requests to query/update a database from a large number of clients, then spawn a new server agent for each request and delete it when finished, but then the listening agent becomes the single process bottleneck. All that would have been done is remove the bottleneck down the path one step, and incur network delay, and the time it takes to spawn and delete the child processes along the way.
The fix for this is of course to have the spawned query agents, let’s call them, respond DIRECTLY BACK to the original instances of the apps as opposed to the listening agent. This would free up the spawning agent from having to handle the callbacks itself. A passive system of sorts. Hmmm… doable I think.
On Dec 31, 2020, at 9:22 AM, Bob Sneidar <bobsneidar at iotecdigital.com<mailto:bobsneidar at iotecdigital.com>> wrote:
You can also try using callbacks, although the callback will not get processed until the next idle message (script execution termination or wait with messages).
On Dec 31, 2020, at 8:53 AM, Rick Harrison via use-livecode <use-livecode at lists.runrev.com<mailto:use-livecode at lists.runrev.com>> wrote:
What version of Raspberry PI are you using?
If you are using an older version of Raspberry PI just replacing it
with a newer version might be your best work around. The older
PI’s are pretty slow. Have you looked into Banana PI for instance?
While LC isn’t multi-threaded there may be a work around which
could make it behave as though it was. Have you tried Send in Time?
How often are you telling your stepper motor to run? Once in every
10 milliseconds or once in every 20 milliseconds etc?
More information about the use-livecode