Fix ruby_whisper_lock_gvl and ruby_whisper_unlock_gvl
This commit is contained in:
parent
d9b0dd1fbe
commit
9deffc6d41
|
|
@ -109,15 +109,15 @@ static VALUE ruby_whisper_s_finalize_log_callback(VALUE self, VALUE id) {
|
|||
}
|
||||
|
||||
void
|
||||
ruby_whisper_lock_gvl(void)
|
||||
ruby_whisper_gvl_locked(void)
|
||||
{
|
||||
is_without_gvl = true;
|
||||
is_without_gvl = false;
|
||||
}
|
||||
|
||||
void
|
||||
ruby_whisper_unlock_gvl(void)
|
||||
ruby_whisper_gvl_unlocked(void)
|
||||
{
|
||||
is_without_gvl = false;
|
||||
is_without_gvl = true;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ extern VALUE ruby_whisper_transcribe(int argc, VALUE *argv, VALUE self);
|
|||
extern VALUE rb_whisper_model_s_new(VALUE context);
|
||||
extern VALUE rb_whisper_segment_s_new(VALUE context, int index);
|
||||
extern void prepare_transcription(ruby_whisper_params *rwp, VALUE *context, int n_processors);
|
||||
extern void ruby_whisper_lock_gvl(void);
|
||||
extern void ruby_whisper_unlock_gvl(void);
|
||||
extern void ruby_whisper_gvl_locked(void);
|
||||
extern void ruby_whisper_gvl_unlocked(void);
|
||||
|
||||
ID transcribe_option_names[1];
|
||||
|
||||
|
|
@ -454,7 +454,7 @@ release_samples(VALUE rb_parsed_args)
|
|||
static void*
|
||||
full_without_gvl(void *rb_args)
|
||||
{
|
||||
ruby_whisper_unlock_gvl();
|
||||
ruby_whisper_gvl_unlocked();
|
||||
|
||||
full_without_gvl_args *args = (full_without_gvl_args *)rb_args;
|
||||
args->result = whisper_full(args->context, *args->params, args->samples, args->n_samples);
|
||||
|
|
@ -492,7 +492,7 @@ full_body(VALUE rb_args)
|
|||
rwp->abort_callback_container,
|
||||
};
|
||||
rb_thread_call_without_gvl(full_without_gvl, (void *)&full_without_gvl_args, full_ubf, (void *)&full_ubf_args);
|
||||
ruby_whisper_lock_gvl();
|
||||
ruby_whisper_gvl_locked();
|
||||
return INT2NUM(full_without_gvl_args.result);
|
||||
}
|
||||
|
||||
|
|
@ -534,7 +534,7 @@ VALUE ruby_whisper_full(int argc, VALUE *argv, VALUE self)
|
|||
static void*
|
||||
full_parallel_without_gvl(void *rb_args)
|
||||
{
|
||||
ruby_whisper_unlock_gvl();
|
||||
ruby_whisper_gvl_unlocked();
|
||||
|
||||
full_parallel_without_gvl_args *args = (full_parallel_without_gvl_args *)rb_args;
|
||||
args->result = whisper_full_parallel(args->context, *args->params, args->samples, args->n_samples, args->n_processors);
|
||||
|
|
@ -565,7 +565,7 @@ full_parallel_body(VALUE rb_args)
|
|||
rwp->abort_callback_container,
|
||||
};
|
||||
rb_thread_call_without_gvl(full_parallel_without_gvl, (void *)&full_parallel_without_gvl_args, full_ubf, (void *)&full_ubf_args);
|
||||
ruby_whisper_lock_gvl();
|
||||
ruby_whisper_gvl_locked();
|
||||
return INT2NUM(full_parallel_without_gvl_args.result);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ extern VALUE mWhisper;
|
|||
|
||||
extern ID id_call;
|
||||
|
||||
extern void ruby_whisper_lock_gvl(void);
|
||||
extern void ruby_whisper_unlock_gvl(void);
|
||||
extern void ruby_whisper_gvl_locked(void);
|
||||
extern void ruby_whisper_gvl_unlocked(void);
|
||||
extern VALUE ruby_whisper_normalize_model_path(VALUE model_path);
|
||||
extern VALUE rb_whisper_segment_s_new(VALUE context, int index);
|
||||
extern const rb_data_type_t ruby_whisper_vad_params_type;
|
||||
|
|
@ -139,7 +139,7 @@ typedef struct {
|
|||
|
||||
static void*
|
||||
call_new_segment_callbacks(void *v_args) {
|
||||
ruby_whisper_lock_gvl();
|
||||
ruby_whisper_gvl_locked();
|
||||
|
||||
call_new_segment_callbacks_args *args = (call_new_segment_callbacks_args *)v_args;
|
||||
const ruby_whisper_callback_container *container = args->container;
|
||||
|
|
@ -183,7 +183,7 @@ static void new_segment_callback(struct whisper_context *ctx, struct whisper_sta
|
|||
n_new
|
||||
};
|
||||
rb_thread_call_with_gvl(call_new_segment_callbacks, (void *)&args);
|
||||
ruby_whisper_unlock_gvl();
|
||||
ruby_whisper_gvl_unlocked();
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -194,7 +194,7 @@ typedef struct {
|
|||
|
||||
static void*
|
||||
call_progress_callbacks(void *v_args) {
|
||||
ruby_whisper_lock_gvl();
|
||||
ruby_whisper_gvl_locked();
|
||||
|
||||
call_progress_callbacks_args *args = (call_progress_callbacks_args *)v_args;
|
||||
const ruby_whisper_callback_container *container = args->container;
|
||||
|
|
@ -232,7 +232,7 @@ static void progress_callback(struct whisper_context *ctx, struct whisper_state
|
|||
progress_cur
|
||||
};
|
||||
rb_thread_call_with_gvl(call_progress_callbacks, (void *)&args);
|
||||
ruby_whisper_unlock_gvl();
|
||||
ruby_whisper_gvl_unlocked();
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -243,7 +243,7 @@ typedef struct {
|
|||
|
||||
static void*
|
||||
call_encoder_begin_callbacks(void *v_args) {
|
||||
ruby_whisper_lock_gvl();
|
||||
ruby_whisper_gvl_locked();
|
||||
|
||||
call_encoder_begin_callbacks_args *args = (call_encoder_begin_callbacks_args *)v_args;
|
||||
const ruby_whisper_callback_container *container = args->container;
|
||||
|
|
@ -288,7 +288,7 @@ static bool encoder_begin_callback(struct whisper_context *ctx, struct whisper_s
|
|||
true
|
||||
};
|
||||
rb_thread_call_with_gvl(call_encoder_begin_callbacks, (void *)&args);
|
||||
ruby_whisper_unlock_gvl();
|
||||
ruby_whisper_gvl_unlocked();
|
||||
|
||||
return args.is_continued;
|
||||
}
|
||||
|
|
@ -301,7 +301,7 @@ typedef struct {
|
|||
|
||||
static void*
|
||||
call_abort_callbacks(void *v_args) {
|
||||
ruby_whisper_lock_gvl();
|
||||
ruby_whisper_gvl_locked();
|
||||
|
||||
call_abort_callbacks_args *args = (call_abort_callbacks_args *)v_args;
|
||||
const ruby_whisper_abort_callback_container *container = args->container;
|
||||
|
|
@ -354,7 +354,7 @@ static bool abort_callback(void * user_data) {
|
|||
false
|
||||
};
|
||||
rb_thread_call_with_gvl(call_abort_callbacks, (void *)&args);
|
||||
ruby_whisper_unlock_gvl();
|
||||
ruby_whisper_gvl_unlocked();
|
||||
|
||||
return args.is_interrupted;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ extern ID id_to_path;
|
|||
extern ID transcribe_option_names[1];
|
||||
|
||||
extern void prepare_transcription(ruby_whisper_params * rwp, VALUE * self, int n_processors);
|
||||
extern void ruby_whisper_lock_gvl(void);
|
||||
extern void ruby_whisper_unlock_gvl(void);
|
||||
extern void ruby_whisper_gvl_locked(void);
|
||||
extern void ruby_whisper_gvl_unlocked(void);
|
||||
|
||||
typedef struct transcribe_without_gvl_args {
|
||||
struct whisper_context *context;
|
||||
|
|
|
|||
Loading…
Reference in New Issue