Debian Codegraph @

R/R_zmq_context.r

raw symbols SCIP
1 #' Context Functions
2 #'
3 #' Context functions
4 #'
5 #' \code{zmq.ctx.new()} initializes a ZMQ context for starting communication.
6 #'
7 #' \code{zmq.ctx.destroy()} terminates the context for stopping communication.
8 #'
9 #' @param ctx
10 #' a ZMQ context
11 #'
12 #' @return
13 #' \code{zmq.ctx.new()} returns an R external pointer (\code{ctx})
14 #' generated by ZMQ C API pointing to a context if successful, otherwise
15 #' returns an R \code{NULL}.
16 #'
17 #' \code{zmq.ctx.destroy()} returns 0 if successful, otherwise returns -1 and
18 #' sets \code{errno} to either \code{EFAULT} or \code{EINTR}.
19 #'
20 #' @author Wei-Chen Chen \email{wccsnow@@gmail.com}.
21 #'
22 #' @references ZeroMQ/4.1.0 API Reference:
23 #' \url{http://api.zeromq.org/4-1:_start}
24 #'
25 #' Programming with Big Data in R Website: \url{https://pbdr.org/}
26 #'
27 #' @examples
28 #' \dontrun{
29 #' library(pbdZMQ, quietly = TRUE)
30 #'
31 #' context <- zmq.ctx.new()
32 #' zmq.ctx.destroy(context)
33 #' }
34 #'
35 #' @keywords programming
36 #' @seealso \code{\link{zmq.socket}()}, \code{\link{zmq.close}()},
37 #' \code{\link{zmq.bind}()}, \code{\link{zmq.connect}()}.
38 #' @rdname a0_d_context
39 #' @name Context Functions
40 NULL
41
42
43
44 #' @rdname a0_d_context
45 #' @export
46 zmq.ctx.new <- function(){
47 ret <- .Call("R_zmq_ctx_new", PACKAGE = "pbdZMQ")
48 ### Users are responsible to take care free and gc.
49 # reg.finalizer(ret, zmq.ctx.destroy, TRUE)
50 ret
51 }
52
53
54
55 #' @rdname a0_d_context
56 #' @export
57 zmq.ctx.destroy <- function(ctx){
58 .Call("R_zmq_ctx_destroy", ctx, PACKAGE = "pbdZMQ")
59 invisible()
60 }
61