From 776f6591a902ddae95fcca288b3988efdd5ac355 Mon Sep 17 00:00:00 2001 From: BlackMinou Date: Tue, 7 Apr 2015 11:26:27 +0200 Subject: [PATCH] Add a method with return value in threaded_example Signed-off-by: BlackMinou --- lib/pthreads/examples/threaded_example.nit | 12 +++++++++++- tests/sav/threaded_example.res | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/pthreads/examples/threaded_example.nit b/lib/pthreads/examples/threaded_example.nit index 9a0af4b..fb0609b 100644 --- a/lib/pthreads/examples/threaded_example.nit +++ b/lib/pthreads/examples/threaded_example.nit @@ -32,7 +32,17 @@ fun bar(i : Int, s : String) is threaded do print s end +# Parameterized `threaded` method with a return type +fun baz(i : Int, j : Int): Int is threaded do + sys.nanosleep(10, 0) + return i + j +end + +print "main" foo bar(10, "parameterized and threaded") -print "main" sys.nanosleep(5,0) +var x = baz(2, 3) +print "main, waiting for baz" +var y = x.join +print("baz result : " + y.to_s) diff --git a/tests/sav/threaded_example.res b/tests/sav/threaded_example.res index e90aa48..4f1025c 100644 --- a/tests/sav/threaded_example.res +++ b/tests/sav/threaded_example.res @@ -2,3 +2,5 @@ main threaded 10 parameterized and threaded +main, waiting for baz +baz result : 5 -- 1.7.9.5