Skip to content

Commit 49884ac

Browse files
committed
cont : proper singleton impl
1 parent f3f2c02 commit 49884ac

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

common/log.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -296,18 +296,9 @@ struct gpt_log * gpt_log_init() {
296296
}
297297

298298
struct gpt_log * gpt_log_main() {
299-
// this is supposed to be thread-safe but sanitizer complains
300-
// https://github.com/ggerganov/llama.cpp/actions/runs/10815973423/job/30006101803?pr=9418#step:6:3731
301-
//static struct gpt_log * log = gpt_log_init();
302-
303-
// let's try this instead
304-
static struct gpt_log * log = nullptr;
305-
static std::once_flag flag;
306-
std::call_once(flag, []() {
307-
log = gpt_log_init();
308-
});
309-
310-
return log;
299+
static struct gpt_log log{256};
300+
301+
return &log;
311302
}
312303

313304
void gpt_log_pause(struct gpt_log * log) {

tests/test-log.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,5 @@ int main() {
3333
threads[i].join();
3434
}
3535

36-
gpt_log_free(gpt_log_main());
37-
3836
return 0;
3937
}

0 commit comments

Comments
 (0)