Browse code

use register() to get default ParallelParam; Team e.g. on Reducer man page

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/Streamer@68971 bc3139a8-67e5-0310-9ffc-ced21a209358

Martin Morgan authored on 30/08/2012 20:02:57
Showing 2 changed files

... ...
@@ -1,7 +1,7 @@
1 1
 setMethod("Team", c(param="missing"),
2 2
     function(FUN, ..., param)
3 3
 {
4
-    param <- parallelRegister()$param
4
+    param <- register()$param
5 5
     if (!param$inUse)
6 6
         if (.Platform$OS.type == "unix")
7 7
             param <- MulticoreParam()
... ...
@@ -56,12 +56,21 @@ Reducer(FUN, init, ..., yieldNth = NA_integer_)
56 56
 
57 57
 \examples{
58 58
 s <- stream(Seq(to=10), Reducer("+"))
59
-yield(s)     ## sum(1:10)
59
+yield(s)     ## sum(1:10), i.e., Reduce over the entire stream
60 60
 s <- stream(Seq(to=10), Reducer("+", yieldNth=5))
61 61
 yield(s)     ## sum(1:5)
62 62
 yield(s)     ## sum(6:10)
63 63
 s <- stream(Seq(to=10), Reducer("+", init=10, yieldNth=5))
64 64
 sapply(s, c) ## 10 + c(sum(1:5), sum(6:10))
65
+if (.Platform$OS.type != "windows") {
66
+    s <- stream(Seq(to=10),
67
+                Team(function(i) { Sys.sleep(1); i },
68
+                     param=MulticoreParam(10L)),
69
+                Reducer("+"))
70
+    system.time(y <- yield(s))
71
+    y
72
+}
73
+
65 74
 }
66 75
 
67 76
 \keyword{classes}