Revert Join log callback thread in a log queue function

This commit is contained in:
Kitaiti Makoto 2026-05-27 07:25:32 +09:00
parent 31d254cceb
commit b6170aa6e4
2 changed files with 11 additions and 12 deletions

View File

@ -3,10 +3,6 @@
#define LOG_QUEUE_CAPACITY 256
#define LOG_DEFAULT_CAPACITY 1024
extern ID id_log_callback_thread;
extern ID id_alive;
extern ID id_join;
void
ruby_whisper_log_queue_initialize(ruby_whisper_log_queue *log_queue)
{
@ -45,7 +41,7 @@ ruby_whisper_log_queue_open(ruby_whisper_log_queue *log_queue)
}
void
ruby_whisper_log_queue_close(ruby_whisper_log_queue *log_queue, VALUE *mod)
ruby_whisper_log_queue_close(ruby_whisper_log_queue *log_queue)
{
rb_nativethread_lock_lock(&log_queue->lock);
@ -53,11 +49,6 @@ ruby_whisper_log_queue_close(ruby_whisper_log_queue *log_queue, VALUE *mod)
rb_native_cond_broadcast(&log_queue->cond);
rb_nativethread_lock_unlock(&log_queue->lock);
VALUE log_callback_thread = rb_ivar_get(*mod, id_log_callback_thread);
if (!NIL_P(log_callback_thread) && RTEST(rb_funcall(log_callback_thread, id_alive, 0))) {
rb_funcall(log_callback_thread, id_join, 0);
}
}
static size_t

View File

@ -5,11 +5,14 @@
extern VALUE mParakeet;
extern VALUE mLogSettable;
extern ID id_extended;
extern ID id_log_callback_thread;
extern ID id_start_log_callback_thread;
extern ID id_alive;
extern ID id_join;
extern void ruby_whisper_log_queue_initialize(ruby_whisper_log_queue *log_queue);
extern void ruby_whisper_log_queue_open(ruby_whisper_log_queue *log_queue);
extern void ruby_whisper_log_queue_close(ruby_whisper_log_queue *log_queue, VALUE *mod);
extern void ruby_whisper_log_queue_close(ruby_whisper_log_queue *log_queue);
extern void ruby_whisper_log_queue_enqueue(ruby_whisper_log_queue *log_queue, enum ggml_log_level level, const char *text);
extern VALUE ruby_whisper_log_queue_drain(ruby_whisper_log_queue *log_queue);
@ -46,7 +49,12 @@ ruby_whisper_parakeet_s_log_set(VALUE self, VALUE log_callback, VALUE user_data)
static void
ruby_whisper_parakeet_end_proc(VALUE args)
{
ruby_whisper_log_queue_close(&parakeet_log_queue, &mParakeet);
ruby_whisper_log_queue_close(&parakeet_log_queue);
VALUE log_callback_thread = rb_ivar_get(mParakeet, id_log_callback_thread);
if (!NIL_P(log_callback_thread) && RTEST(rb_funcall(log_callback_thread, id_alive, 0))) {
rb_funcall(log_callback_thread, id_join, 0);
}
}
void