From 94ecaa9399b19e3910f9ace429786cb74f8c02e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Tue, 10 Oct 2023 08:11:33 +0200 Subject: [PATCH] cook: add cook_disable() --- bind/v4k.lua | 1 + depot | 2 +- engine/joint/v4k.h | 10 +++++++++- engine/split/v4k_cooker.c | 9 ++++++++- engine/split/v4k_cooker.h | 1 + engine/v4k.c | 9 ++++++++- engine/v4k.h | 1 + 7 files changed, 29 insertions(+), 4 deletions(-) diff --git a/bind/v4k.lua b/bind/v4k.lua index 77d0f34..5dfe7b8 100644 --- a/bind/v4k.lua +++ b/bind/v4k.lua @@ -2081,6 +2081,7 @@ COOK_DEBUGLOG = 4, bool cook_start( const char *path_to_cook_ini, const char *masks, int flags ); void cook_stop(); void cook_cancel(); + void cook_disable(); int cook_jobs(); int cook_progress(); typedef union json_t { char* s; double f; int64_t i; uintptr_t p; union json_t* arr; } json_t; diff --git a/depot b/depot index bf6f1c4..8eb9226 160000 --- a/depot +++ b/depot @@ -1 +1 @@ -Subproject commit bf6f1c4d6a445fae7e8df1746d9c1f0569b52caf +Subproject commit 8eb9226fcff6bdbbb5ddb28741575066aad494f5 diff --git a/engine/joint/v4k.h b/engine/joint/v4k.h index ce09c15..e9892a6 100644 --- a/engine/joint/v4k.h +++ b/engine/joint/v4k.h @@ -15732,6 +15732,7 @@ API void cook_config( const char *path_to_cook_ini ); // "tools/cook.ini" API bool cook_start( const char *path_to_cook_ini, const char *masks, int flags ); // COOK_INI, "**" API void cook_stop(); API void cook_cancel(); +API void cook_disable(); API int cook_jobs(); // [0..N] API int cook_progress(); // [0..100] @@ -586442,12 +586443,19 @@ void cook_cancel() { if( cook_cancelable ) cook_cancelling = true; } +static bool cook_disabled=0; + +void cook_disable() { + cook_disabled=1; +} + int cook_jobs() { int num_jobs = optioni("--cook-jobs", maxf(1.15,app_cores()) * 1.75), max_jobs = countof(jobs); ifdef(ems, num_jobs = 0); - return clampi(num_jobs, 0, max_jobs); + return clampi(num_jobs, 0, cook_disabled?0:max_jobs); } + void cook_config( const char *pathfile_to_cook_ini ) { // @todo: test run-from-"bin/" case on Linux. COOK_INI = pathfile_to_cook_ini; ASSERT( file_exist(COOK_INI) ); diff --git a/engine/split/v4k_cooker.c b/engine/split/v4k_cooker.c index 244bfe9..26d7f7e 100644 --- a/engine/split/v4k_cooker.c +++ b/engine/split/v4k_cooker.c @@ -805,12 +805,19 @@ void cook_cancel() { if( cook_cancelable ) cook_cancelling = true; } +static bool cook_disabled=0; + +void cook_disable() { + cook_disabled=1; +} + int cook_jobs() { int num_jobs = optioni("--cook-jobs", maxf(1.15,app_cores()) * 1.75), max_jobs = countof(jobs); ifdef(ems, num_jobs = 0); - return clampi(num_jobs, 0, max_jobs); + return clampi(num_jobs, 0, cook_disabled?0:max_jobs); } + void cook_config( const char *pathfile_to_cook_ini ) { // @todo: test run-from-"bin/" case on Linux. COOK_INI = pathfile_to_cook_ini; ASSERT( file_exist(COOK_INI) ); diff --git a/engine/split/v4k_cooker.h b/engine/split/v4k_cooker.h index 29ebfa0..fbcbe30 100644 --- a/engine/split/v4k_cooker.h +++ b/engine/split/v4k_cooker.h @@ -26,6 +26,7 @@ API void cook_config( const char *path_to_cook_ini ); // "tools/cook.ini" API bool cook_start( const char *path_to_cook_ini, const char *masks, int flags ); // COOK_INI, "**" API void cook_stop(); API void cook_cancel(); +API void cook_disable(); API int cook_jobs(); // [0..N] API int cook_progress(); // [0..100] diff --git a/engine/v4k.c b/engine/v4k.c index 6807ed1..8da6a8e 100644 --- a/engine/v4k.c +++ b/engine/v4k.c @@ -4619,12 +4619,19 @@ void cook_cancel() { if( cook_cancelable ) cook_cancelling = true; } +static bool cook_disabled=0; + +void cook_disable() { + cook_disabled=1; +} + int cook_jobs() { int num_jobs = optioni("--cook-jobs", maxf(1.15,app_cores()) * 1.75), max_jobs = countof(jobs); ifdef(ems, num_jobs = 0); - return clampi(num_jobs, 0, max_jobs); + return clampi(num_jobs, 0, cook_disabled?0:max_jobs); } + void cook_config( const char *pathfile_to_cook_ini ) { // @todo: test run-from-"bin/" case on Linux. COOK_INI = pathfile_to_cook_ini; ASSERT( file_exist(COOK_INI) ); diff --git a/engine/v4k.h b/engine/v4k.h index fb547e9..78e11ec 100644 --- a/engine/v4k.h +++ b/engine/v4k.h @@ -1799,6 +1799,7 @@ API void cook_config( const char *path_to_cook_ini ); // "tools/cook.ini" API bool cook_start( const char *path_to_cook_ini, const char *masks, int flags ); // COOK_INI, "**" API void cook_stop(); API void cook_cancel(); +API void cook_disable(); API int cook_jobs(); // [0..N] API int cook_progress(); // [0..100]