From 172ae92b66707ebb3281c95d0289e574c5b78678 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Tue, 14 Jul 2020 10:34:37 +0200 Subject: [PATCH] :art: Shred/Fork get_now --- src/lib/shred.c | 9 +++++++++ tests/fork/fork_now.gw | 3 +++ 2 files changed, 12 insertions(+) create mode 100644 tests/fork/fork_now.gw 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; -- 2.43.0