34 lines
1.0 KiB
C
34 lines
1.0 KiB
C
|
|
// learner_env_box.h - Learning Layer ENV Box
|
|||
|
|
// Purpose: Decide whether CAP Learner thread should run, based on HAKMEM_MODE
|
|||
|
|
// and HAKMEM_LEARN, without touchingホットパス。
|
|||
|
|
//
|
|||
|
|
// Priority:
|
|||
|
|
// 1. HAKMEM_LEARN is set → 0/1 で明示的に上書き
|
|||
|
|
// 2. 未設定の場合:
|
|||
|
|
// HAKMEM_MODE=learning/research → Learner 有効
|
|||
|
|
// それ以外(minimal/fast/balanced) → Learner 無効
|
|||
|
|
|
|||
|
|
#pragma once
|
|||
|
|
|
|||
|
|
#include "../hakmem_config.h"
|
|||
|
|
#include <stdlib.h>
|
|||
|
|
|
|||
|
|
static inline int hak_learner_env_should_run(void) {
|
|||
|
|
static int g_inited = 0;
|
|||
|
|
static int g_effective = 0;
|
|||
|
|
if (__builtin_expect(!g_inited, 0)) {
|
|||
|
|
const char* e = getenv("HAKMEM_LEARN");
|
|||
|
|
if (e && *e) {
|
|||
|
|
int v = atoi(e);
|
|||
|
|
g_effective = (v != 0) ? 1 : 0;
|
|||
|
|
} else {
|
|||
|
|
HakemMode m = g_hakem_config.mode;
|
|||
|
|
g_effective =
|
|||
|
|
(m == HAKMEM_MODE_LEARNING || m == HAKMEM_MODE_RESEARCH) ? 1 : 0;
|
|||
|
|
}
|
|||
|
|
g_inited = 1;
|
|||
|
|
}
|
|||
|
|
return g_effective;
|
|||
|
|
}
|
|||
|
|
|