Skip to content

Commit

Permalink
Merge pull request #173 from marcgurevitx/true-os-sleep
Browse files Browse the repository at this point in the history
True OS sleep on yield() and wait()
  • Loading branch information
JoeStrout authored Jul 28, 2024
2 parents 11d594e + f2b2e42 commit d1f2fcb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions MiniScript-cpp/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <iostream>
#include <fstream>
#include <string>
#include <chrono>
#include <thread>
#include "MiniScript/SimpleString.h"
#include "MiniScript/UnicodeUtil.h"
#include "MiniScript/UnitTest.h"
Expand All @@ -22,6 +24,9 @@
#include "ShellIntrinsics.h"
#include "DateTimeUtils.h" // TEMP for initial testing

// YIELD_NANOSECONDS: How many nano-seconds to sleep when yielding.
#define YIELD_NANOSECONDS 10000000

using namespace MiniScript;

bool printHeaderInfo = true;
Expand Down Expand Up @@ -127,6 +132,7 @@ static int DoCommand(Interpreter &interp, String cmd) {
while (!interp.Done()) {
try {
interp.RunUntilDone();
std::this_thread::sleep_for(std::chrono::nanoseconds(YIELD_NANOSECONDS));
} catch (MiniscriptException& mse) {
std::cerr << "Runtime Exception: " << mse.message << std::endl;
interp.vm->Stop();
Expand Down

0 comments on commit d1f2fcb

Please sign in to comment.