From 36a7868b0bc3b6d95d0083c5ed52452c6e71ef9d Mon Sep 17 00:00:00 2001 From: ValKmjolnir Date: Mon, 23 May 2022 22:12:58 +0800 Subject: [PATCH] :memo: add maketimer_multi_coroutine_test(vm_num) in test/maketimer_sim.nas --- makefile | 2 ++ test/maketimer_sim.nas | 51 +++++++++++++++++++++++++++++++++++++----- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/makefile b/makefile index 050b851..f1fe9e4 100644 --- a/makefile +++ b/makefile @@ -7,6 +7,7 @@ nasal.exe:main.cpp nasal_ast.h nasal_err.h nasal_builtin.h nasal_opt.h nasal_cod g++ -std=c++11 -O3 main.cpp -o nasal.exe -fno-exceptions -Wshadow -Wall -static test:nasal @ ./nasal -op -e test/ascii-art.nas + @ ./nasal -op -c test/auto_crash.nas @ ./nasal -op -a -c test/bf.nas @ ./nasal -op -a -c test/bfcolored.nas @ ./nasal -op -a -c test/bfconvertor.nas @@ -27,6 +28,7 @@ test:nasal @ ./nasal -op -e -d test/lexer.nas @ ./nasal -op -e -d test/life.nas @ ./nasal -op -t test/loop.nas + @ ./nasal -op -c test/maketimer_sim.nas @ ./nasal -op -t -d test/mandel.nas @ ./nasal -op -t -d test/mandelbrot.nas @ ./nasal -op -t -d -o test/md5.nas diff --git a/test/maketimer_sim.nas b/test/maketimer_sim.nas index a843905..a74ae68 100644 --- a/test/maketimer_sim.nas +++ b/test/maketimer_sim.nas @@ -1,22 +1,30 @@ -var process=nil; var task={}; var event={}; var add_event=func(name,interval,function){ event[name]=coroutine.create(func{ - unix.sleep(interval); - println("[event] ",name); + var timestamp=maketimestamp(); + timestamp.stamp(); + while(timestamp.elapsedMSec()