Jump to content
Sign in to follow this  
ArMaTeC

BIKIScheduler

Recommended Posts

Better explanation on the scheduler

← Older revision Revision as of 01:04, 16 July 2017
Line 11: Line 11:
 
As described below there is no way to predict when scheduled code will have finished, although you can use the command [[scriptDone]] with the provided [[Script (Handle)|Script handle]] to query if the thread execution has finished and there is also the command [[terminate]] to abort the thread.
 
As described below there is no way to predict when scheduled code will have finished, although you can use the command [[scriptDone]] with the provided [[Script (Handle)|Script handle]] to query if the thread execution has finished and there is also the command [[terminate]] to abort the thread.
   
The advantage of scheduled code is that it runs parallel (fire and forget) and that you are able to run code with a huge performance impact (nearly) without slowing down the game.
+
The advantage of scheduled code is that it runs asynchonously in the background and that you are able to run code with a huge performance impact (nearly) without slowing down the game.
   
A scheduled script runs for exactly 3ms before it is put in suspension to be resumed on the next frame, again for another 3ms and so on until the script is finished. The amount of suspension depends on FPS. At 20 FPS the duration of suspension for example is 50ms.
+
All scheduled scripts can run for a maximum of 3ms in a frame. Each Script that runs add's up to the total runtime and as soon as the total runtime of 3ms is reached the current script is paused and the game continues calculating everything else it needs to calculate that frame (For example sound and graphics rendering). On the next frame the scheduler again starts to run scripts for 3ms, starting with the script which hasn't been executed for the longest time.
This means that if a scheduled script cannot be completed under 3ms, the execution can stretch for undefined amount of time, subject to engine load, FPS and other non scheduled scripts running at the same time. A while true loop with sleep started in scheduled environment therefore has little chance to follow with exact interval.  
+
   
Scheduled scripts always start with slight delay, subject to engine load.  
+
This means any script that ran as the 3ms runtime was reached will be paused in the middle of it's execution and depending on how many scripts are spawned it might take several frames till it will run again.
  +
A while true loop with sleep started in scheduled environment therefore has little chance to follow with exact interval.
  +
 
  +
If you spawn a scheduled script it will only start to run in the next frame when the scheduler starts fresh again.
   
 
== Where code starts scheduled ==
 
== Where code starts scheduled ==

View the full article

Share this post


Link to post
Share on other sites
Sign in to follow this  

×

Important Information

City Life RPG mod for ARMA 3
Copyright © 2017 City Life RPG. All rights reserved.
Registered with the UK Copyright Service. Registration No: 284659128

Positive SSL on a transparent background ipv6 ready DMCA.com Protection Status