Modify example to add a parametrized threaded fun
authorBlackMinou <romain.chanoir@viacesi.fr>
Wed, 1 Apr 2015 06:57:42 +0000 (08:57 +0200)
committerBlackMinou <romain.chanoir@viacesi.fr>
Fri, 3 Apr 2015 04:27:44 +0000 (06:27 +0200)
Signed-off-by: BlackMinou <romain.chanoir@viacesi.fr>

lib/pthreads/examples/threaded_example.nit
tests/sav/threaded_example.res

index 175c753..9a0af4b 100644 (file)
@@ -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)
index 050d79d..e90aa48 100644 (file)
@@ -1,2 +1,4 @@
 main
 threaded
+10
+parameterized and threaded