cook: add cook_disable()

main
Dominik Madarász 2023-10-10 08:11:33 +02:00
parent 69373cea50
commit 94ecaa9399
7 changed files with 29 additions and 4 deletions

View File

@ -2081,6 +2081,7 @@ COOK_DEBUGLOG = 4,
bool cook_start( const char *path_to_cook_ini, const char *masks, int flags ); bool cook_start( const char *path_to_cook_ini, const char *masks, int flags );
void cook_stop(); void cook_stop();
void cook_cancel(); void cook_cancel();
void cook_disable();
int cook_jobs(); int cook_jobs();
int cook_progress(); int cook_progress();
typedef union json_t { char* s; double f; int64_t i; uintptr_t p; union json_t* arr; } json_t; typedef union json_t { char* s; double f; int64_t i; uintptr_t p; union json_t* arr; } json_t;

2
depot

@ -1 +1 @@
Subproject commit bf6f1c4d6a445fae7e8df1746d9c1f0569b52caf Subproject commit 8eb9226fcff6bdbbb5ddb28741575066aad494f5

View File

@ -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 bool cook_start( const char *path_to_cook_ini, const char *masks, int flags ); // COOK_INI, "**"
API void cook_stop(); API void cook_stop();
API void cook_cancel(); API void cook_cancel();
API void cook_disable();
API int cook_jobs(); // [0..N] API int cook_jobs(); // [0..N]
API int cook_progress(); // [0..100] API int cook_progress(); // [0..100]
@ -586442,12 +586443,19 @@ void cook_cancel() {
if( cook_cancelable ) cook_cancelling = true; if( cook_cancelable ) cook_cancelling = true;
} }
static bool cook_disabled=0;
void cook_disable() {
cook_disabled=1;
}
int cook_jobs() { int cook_jobs() {
int num_jobs = optioni("--cook-jobs", maxf(1.15,app_cores()) * 1.75), max_jobs = countof(jobs); int num_jobs = optioni("--cook-jobs", maxf(1.15,app_cores()) * 1.75), max_jobs = countof(jobs);
ifdef(ems, num_jobs = 0); 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. void cook_config( const char *pathfile_to_cook_ini ) { // @todo: test run-from-"bin/" case on Linux.
COOK_INI = pathfile_to_cook_ini; COOK_INI = pathfile_to_cook_ini;
ASSERT( file_exist(COOK_INI) ); ASSERT( file_exist(COOK_INI) );

View File

@ -805,12 +805,19 @@ void cook_cancel() {
if( cook_cancelable ) cook_cancelling = true; if( cook_cancelable ) cook_cancelling = true;
} }
static bool cook_disabled=0;
void cook_disable() {
cook_disabled=1;
}
int cook_jobs() { int cook_jobs() {
int num_jobs = optioni("--cook-jobs", maxf(1.15,app_cores()) * 1.75), max_jobs = countof(jobs); int num_jobs = optioni("--cook-jobs", maxf(1.15,app_cores()) * 1.75), max_jobs = countof(jobs);
ifdef(ems, num_jobs = 0); 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. void cook_config( const char *pathfile_to_cook_ini ) { // @todo: test run-from-"bin/" case on Linux.
COOK_INI = pathfile_to_cook_ini; COOK_INI = pathfile_to_cook_ini;
ASSERT( file_exist(COOK_INI) ); ASSERT( file_exist(COOK_INI) );

View File

@ -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 bool cook_start( const char *path_to_cook_ini, const char *masks, int flags ); // COOK_INI, "**"
API void cook_stop(); API void cook_stop();
API void cook_cancel(); API void cook_cancel();
API void cook_disable();
API int cook_jobs(); // [0..N] API int cook_jobs(); // [0..N]
API int cook_progress(); // [0..100] API int cook_progress(); // [0..100]

View File

@ -4619,12 +4619,19 @@ void cook_cancel() {
if( cook_cancelable ) cook_cancelling = true; if( cook_cancelable ) cook_cancelling = true;
} }
static bool cook_disabled=0;
void cook_disable() {
cook_disabled=1;
}
int cook_jobs() { int cook_jobs() {
int num_jobs = optioni("--cook-jobs", maxf(1.15,app_cores()) * 1.75), max_jobs = countof(jobs); int num_jobs = optioni("--cook-jobs", maxf(1.15,app_cores()) * 1.75), max_jobs = countof(jobs);
ifdef(ems, num_jobs = 0); 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. void cook_config( const char *pathfile_to_cook_ini ) { // @todo: test run-from-"bin/" case on Linux.
COOK_INI = pathfile_to_cook_ini; COOK_INI = pathfile_to_cook_ini;
ASSERT( file_exist(COOK_INI) ); ASSERT( file_exist(COOK_INI) );

View File

@ -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 bool cook_start( const char *path_to_cook_ini, const char *masks, int flags ); // COOK_INI, "**"
API void cook_stop(); API void cook_stop();
API void cook_cancel(); API void cook_cancel();
API void cook_disable();
API int cook_jobs(); // [0..N] API int cook_jobs(); // [0..N]
API int cook_progress(); // [0..100] API int cook_progress(); // [0..100]