SPAWN and CALL, two different ways to start the execution of script code.
CALL: The fast, resource saving, serial way.
If we use CALL to execute a piece of code, we ensure that the script is running as fast as currently possible. This is the prefered way to execute our code with less resource consumption at all.
SPAWN: The slow, parallel way.
When we are forced to use SPAWN instead of CALL?
There are only two reasons to prefer SPAWN.
1. If we can't avoid the use of SLEEP or WAITUNTIL to ensure a specific timing.
2. If the calling code cant wait for termination of the called code, because the called code contains very large loops (>10000) or the called code produce other large delays by waiting for external returns (>100ms).
If we cant avoid the use of SPAWN, we have to ensure that we never risk a situation, where our SPAWNed scripts are ACCUMULATED to much.
Accumulation occurs, if the execution time of our script is larger then the calling period.
For example we have a script which is SPAWNed every second, but the execution time of this script on a loaded server is 3 seconds (execution times depends on load and can be many minutes). This means the number of concurrently running scripts will increase permanently. And the secondary effect is, that the execution time of the same script increases too (our timing will be not as expected).
And we have to realize, that all other SPAWNed scripts currently running are slowed down significantly (timing broken), if such accumulation occurs.
CONCLUSION:
Generally, the periodical and/or frequently use of SPAWN is critical (especially on servers), we should prefer using CALL where ever possible!!!
Thats all, thanks for your attention
CALL: The fast, resource saving, serial way.
If we use CALL to execute a piece of code, we ensure that the script is running as fast as currently possible. This is the prefered way to execute our code with less resource consumption at all.
SPAWN: The slow, parallel way.
When we are forced to use SPAWN instead of CALL?
There are only two reasons to prefer SPAWN.
1. If we can't avoid the use of SLEEP or WAITUNTIL to ensure a specific timing.
2. If the calling code cant wait for termination of the called code, because the called code contains very large loops (>10000) or the called code produce other large delays by waiting for external returns (>100ms).
If we cant avoid the use of SPAWN, we have to ensure that we never risk a situation, where our SPAWNed scripts are ACCUMULATED to much.
Accumulation occurs, if the execution time of our script is larger then the calling period.
For example we have a script which is SPAWNed every second, but the execution time of this script on a loaded server is 3 seconds (execution times depends on load and can be many minutes). This means the number of concurrently running scripts will increase permanently. And the secondary effect is, that the execution time of the same script increases too (our timing will be not as expected).
And we have to realize, that all other SPAWNed scripts currently running are slowed down significantly (timing broken), if such accumulation occurs.
CONCLUSION:
Generally, the periodical and/or frequently use of SPAWN is critical (especially on servers), we should prefer using CALL where ever possible!!!
Thats all, thanks for your attention