forked from ropensci/rzmq
/
create.sink.Rd
55 lines (52 loc) · 1.43 KB
/
create.sink.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
\name{create.sink}
\alias{create.sink}
\alias{get.sink.results}
\title{
create a sink object.
}
\description{
Create a sink object in a separate thread which acts as an async
reciever for remotely executed jobs.
The job results can be later retreived via get.sink.results.
}
\usage{
create.sink(address, num_items)
get.sink.results(sink)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
\item{address}{the transport endpoint for the remote sink server.}
\item{num_items}{the number of items to indicate the remote job has completed.}
}
\value{
create.sink returns a sink object
get.sink.results returns a list of the remotely executed jobs
}
\references{
http://www.zeromq.org
http://api.zeromq.org
http://zguide.zeromq.org/page:all
}
\author{
ZMQ was written by Martin Sustrik <sustrik@250bpm.com> and Martin Lucina <mato@kotelna.sk>.
rzmq was written by Whit Armstrong.
}
\seealso{
\code{\link{connect.socket},\link{bind.socket},\link{receive.socket},\link{send.socket}}
}
\examples{\dontrun{
## an example in the spirit of lapply
x <- as.list(1:100)
context = init.context()
execution.socket = init.socket(context,"ZMQ_PUSH")
connect.socket(execution.socket,"tcp://my.remote.server:5557")
## listen for results
N <- length(x)
sink <- create.sink("tcp://my.results.server:5558",N)
for(i in 1:N) {
remote.exec(execution.socket,FUN,x[[i]])
}
ans <- get.sink.results(sink)
lapply(ans,unserialize)
}}
\keyword{utilities}