diff --git a/bindings/ruby/ext/ruby_whisper_log_queue.c b/bindings/ruby/ext/ruby_whisper_log_queue.c index 6d623a2f3..713ccf227 100644 --- a/bindings/ruby/ext/ruby_whisper_log_queue.c +++ b/bindings/ruby/ext/ruby_whisper_log_queue.c @@ -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 diff --git a/bindings/ruby/ext/ruby_whisper_parakeet.c b/bindings/ruby/ext/ruby_whisper_parakeet.c index cb1233622..7d8588b67 100644 --- a/bindings/ruby/ext/ruby_whisper_parakeet.c +++ b/bindings/ruby/ext/ruby_whisper_parakeet.c @@ -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(¶keet_log_queue, &mParakeet); + ruby_whisper_log_queue_close(¶keet_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