From: Jérémie Astor Date: Tue, 14 Jul 2020 08:34:37 +0000 (+0200) Subject: :art: Shred/Fork get_now X-Git-Tag: nightly~1435 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=172ae92b66707ebb3281c95d0289e574c5b78678;p=gwion.git :art: Shred/Fork get_now --- diff --git a/src/lib/shred.c b/src/lib/shred.c index bcbf0c95..4f382a1e 100644 --- a/src/lib/shred.c +++ b/src/lib/shred.c @@ -213,6 +213,13 @@ static MFUN(fork_test_cancel) { } } +static MFUN(shred_now) { + VM *vm = shred->info->vm; + while(vm->parent) + vm = vm->parent; + *(m_float*)RETURN = vm->bbq->pos; +} + struct ThreadLauncher { MUTEX_TYPE mutex; THREAD_COND_TYPE cond; @@ -350,6 +357,8 @@ GWION_IMPORT(shred) { GWI_BB(gwi_func_end(gwi, shred_lock, ae_flag_none)) gwi_func_ini(gwi, "void", "unlock"); GWI_BB(gwi_func_end(gwi, shred_unlock, ae_flag_none)) + gwi_func_ini(gwi, "float", "get_now"); + GWI_BB(gwi_func_end(gwi, shred_now, ae_flag_none)) GWI_BB(gwi_class_end(gwi)) struct SpecialId_ spid = { .type=t_shred, .exec=RegPushMe, .is_const=1 }; diff --git a/tests/fork/fork_now.gw b/tests/fork/fork_now.gw new file mode 100644 index 00000000..c019e5c2 --- /dev/null +++ b/tests/fork/fork_now.gw @@ -0,0 +1,3 @@ +samp => now; +fork { <<< me.get_now() >>>; }; +samp => now;