SQFvm / runtime

Custom implementation of the Arma script language SQF
GNU Lesser General Public License v3.0
96 stars 30 forks source link

[BUG] Scheduled executes with blocked unscheduled #184

Closed Coryf88 closed 2 years ago

Coryf88 commented 2 years ago

Describe the bug Blocking the unscheduled environment doesn't prevent the scheduled environment from executing.

To Reproduce

  1. Execute sqfvm.exe -a --sqf "private _iterations = 0; private _handle = 0 spawn {}; while { !scriptDone _handle } do { _iterations = _iterations + 1 }; [scriptDone _handle, _iterations]"
  2. Notice [INF] Context droped with return value '[true, 20]'.

Expected behavior [INF] Context droped with return value '[false, 10000]'.

Screenshots image

Additional context Expected behavior depends on #183 being fixed.

X39 commented 2 years ago

This is actually not a bug with SQF-VM but one of those minor details in which SQF-VM differs from arma behavior.

The technical detail here is that the way, async behavior is archived with SQF-VM, is by regulary suspending all code (essentially having no actual unscheduled code) and thus allowing other script-handles to run. This however means that the "desired" behavior (which really is not desired for SQF-VM) cannot be archived.

Needless to say that i am open for additional input here, eg adding a switch that forces continous execution or an instruction or what not, but will for now mark this as "Wont Fix".