File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
MiniScript-cpp/src/MiniScript Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 1414#include < cmath>
1515#include < ctime>
1616#include < algorithm>
17- #include < chrono>
18- #include < thread>
1917
2018namespace MiniScript {
2119
@@ -857,10 +855,16 @@ namespace MiniScript {
857855 }
858856
859857 static IntrinsicResult intrinsic_wait (Context *context, IntrinsicResult partialResult) {
860- double seconds = context->GetVar (" seconds" ).DoubleValue ();
861- long nanoseconds = seconds * 1000000000 ;
862- std::this_thread::sleep_for (std::chrono::nanoseconds (nanoseconds));
863- return IntrinsicResult::Null;
858+ double now = context->vm ->RunTime ();
859+ if (partialResult.Done ()) {
860+ // Just starting our wait; calculate end time and return as partial result
861+ double interval = context->GetVar (" seconds" ).DoubleValue ();
862+ return IntrinsicResult (Value (now + interval), false );
863+ } else {
864+ // Continue until current time exceeds the time in the partial result
865+ if (now > partialResult.Result ().DoubleValue ()) return IntrinsicResult::Null;
866+ return partialResult;
867+ }
864868 }
865869
866870 static IntrinsicResult intrinsic_yield (Context *context, IntrinsicResult partialResult) {
You can’t perform that action at this time.
0 commit comments