From 5abf871d34f53d4eac6d15e93a5e78567476c6ec Mon Sep 17 00:00:00 2001 From: BlackMinou Date: Wed, 1 Apr 2015 08:57:42 +0200 Subject: [PATCH] Modify example to add a parametrized threaded fun Signed-off-by: BlackMinou --- lib/pthreads/examples/threaded_example.nit | 12 ++++++++++-- tests/sav/threaded_example.res | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/pthreads/examples/threaded_example.nit b/lib/pthreads/examples/threaded_example.nit index 175c753..9a0af4b 100644 --- a/lib/pthreads/examples/threaded_example.nit +++ b/lib/pthreads/examples/threaded_example.nit @@ -19,12 +19,20 @@ module threaded_example import pthreads -# the "is threaded" annotation makes this fun run on an other thread +# the `is threaded` annotation makes this method run on an other thread fun foo is threaded do sys.nanosleep(1,0) print "threaded" end +# Parameterized `threaded` method, same as foo, but with parameters +fun bar(i : Int, s : String) is threaded do + sys.nanosleep(2, 0) + print i + print s +end + foo +bar(10, "parameterized and threaded") print "main" -sys.nanosleep(2,0) +sys.nanosleep(5,0) diff --git a/tests/sav/threaded_example.res b/tests/sav/threaded_example.res index 050d79d..e90aa48 100644 --- a/tests/sav/threaded_example.res +++ b/tests/sav/threaded_example.res @@ -1,2 +1,4 @@ main threaded +10 +parameterized and threaded -- 1.7.9.5