diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-29 10:08:04 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-29 10:08:04 +0200 |
| commit | 8d3fc9f5f9c0593fcae9c451efe6c89c64dcbe84 (patch) | |
| tree | 8c0182f9bf94aaa8afe5126988e07af82c4409fd /src/utils | |
| parent | cdf46d85efe7fa54e8c302a255214341c567b4af (diff) | |
| download | nissy-core-8d3fc9f5f9c0593fcae9c451efe6c89c64dcbe84.tar.gz nissy-core-8d3fc9f5f9c0593fcae9c451efe6c89c64dcbe84.zip | |
Added stop / pause / resume solve to API
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/sleep.h | 48 | ||||
| -rw-r--r-- | src/utils/utils.h | 1 |
2 files changed, 49 insertions, 0 deletions
diff --git a/src/utils/sleep.h b/src/utils/sleep.h new file mode 100644 index 0000000..d618e9b --- /dev/null +++ b/src/utils/sleep.h | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | STATIC void msleep(int); | ||
| 2 | |||
| 3 | #if defined(WIN32) | ||
| 4 | |||
| 5 | #define NISSY_CANSLEEP true | ||
| 6 | |||
| 7 | STATIC void | ||
| 8 | msleep(int milliseconds) | ||
| 9 | { | ||
| 10 | Sleep(milliseconds); | ||
| 11 | } | ||
| 12 | |||
| 13 | #elif defined(__wasm__) | ||
| 14 | |||
| 15 | #include <emscripten.h> | ||
| 16 | |||
| 17 | #define NISSY_CANSLEEP true | ||
| 18 | |||
| 19 | STATIC void | ||
| 20 | msleep(int milliseconds) | ||
| 21 | { | ||
| 22 | emscripten_sleep(milliseconds); | ||
| 23 | } | ||
| 24 | |||
| 25 | #elif defined(__unix__) | ||
| 26 | |||
| 27 | #include <time.h> | ||
| 28 | |||
| 29 | #define NISSY_CANSLEEP true | ||
| 30 | |||
| 31 | STATIC void | ||
| 32 | msleep(int milliseconds) | ||
| 33 | { | ||
| 34 | struct timespec t; | ||
| 35 | t.tv_sec = milliseconds / 1000; | ||
| 36 | t.tv_nsec = (milliseconds % 1000) * 1000000; | ||
| 37 | nanosleep(&t, NULL); | ||
| 38 | } | ||
| 39 | |||
| 40 | #else | ||
| 41 | |||
| 42 | #define NISSY_CANSLEEP false | ||
| 43 | STATIC void | ||
| 44 | msleep(int milliseconds) | ||
| 45 | { | ||
| 46 | } | ||
| 47 | |||
| 48 | #endif | ||
diff --git a/src/utils/utils.h b/src/utils/utils.h index ce4355e..d14b285 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | #include "dbg_log.h" | 1 | #include "dbg_log.h" |
| 2 | #include "constants.h" | 2 | #include "constants.h" |
| 3 | #include "math.h" | 3 | #include "math.h" |
| 4 | #include "sleep.h" | ||
