Add documentation for threaded methods with return value
authorBlackMinou <romain.chanoir@viacesi.fr>
Tue, 7 Apr 2015 13:39:44 +0000 (15:39 +0200)
committerBlackMinou <romain.chanoir@viacesi.fr>
Tue, 14 Apr 2015 06:30:49 +0000 (08:30 +0200)
Signed-off-by: BlackMinou <romain.chanoir@viacesi.fr>

lib/pthreads/README.md

index 4a117b4..44f3754 100644 (file)
@@ -12,7 +12,12 @@ This group also provides two optional modules with thread-safe collections:
 Theses services are implemented using the POSIX threads.
 
 You can also use the `is threaded` annotation on methods, which makes them run on their own thread.
-Methods with return value or self calls are not supported.
+Methods with self calls are not supported.
+
+A method or function annotated with `is threaded` has its return value changed during compilation.
+You will get a subclass of `Thread`, even if there wasn't a return value before. You can know if the threaded method is done with the `is_done` boolean from `Thread`.
+A call to the `join` method will block the execution until the threaded method is done, or immediatly return if it's already done.
+`join` will return an object typed with the orginial return type, or `null` if there wasn't.
 
 ## Known limitations:
 
@@ -24,3 +29,4 @@ Methods with return value or self calls are not supported.
 
 * See: `man pthreads`
 * See: `examples/concurrent_array_and_barrier.nit`
+* See: ̀ examples/threaded_example.nit`