Skip to content

Commit b2b20df

Browse files
committed
update docs for .context()
1 parent 47f42f1 commit b2b20df

File tree

3 files changed

+53
-30
lines changed

3 files changed

+53
-30
lines changed

R/context.R

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@
2525
#' @param socket a Socket.
2626
#' @param ... not used, present for compatibility purposes only.
2727
#'
28-
#' @return For \code{context}: a new Context (object of class 'nanoContext' and
29-
#' 'nano').
30-
#'
31-
#' For \code{.context}: an external pointer.
28+
#' @return A Context (object of class 'nanoContext' and 'nano').
3229
#'
3330
#' @details Contexts allow the independent and concurrent use of stateful
3431
#' operations using the same socket. For example, two different contexts
@@ -45,20 +42,11 @@
4542
#' For nano objects, use the \code{$context_open()} method, which will
4643
#' attach a new context at \code{$context}. See \code{\link{nano}}.
4744
#'
48-
#' \code{.context} is a performance variant of \code{context}, designed to
49-
#' wrap a socket in a function argument when calling \code{\link{request}}
50-
#' or \code{\link{reply}}. External pointers created by \code{.context}
51-
#' are unclassed, hence methods for contexts such as \code{\link{close}}
52-
#' will not work. However they function as a Context would when passed to
53-
#' all messaging functions. The context is automatically closed when the
54-
#' object is garbage collected.
55-
#'
5645
#' @examples
5746
#' s <- socket("req", listen = "inproc://nanonext")
5847
#' ctx <- context(s)
5948
#' ctx
6049
#' close(ctx)
61-
#' r <- request(.context(s), "request data")
6250
#' close(s)
6351
#'
6452
#' n <- nano("req", listen = "inproc://nanonext")
@@ -73,7 +61,26 @@
7361
#'
7462
context <- function(socket, ...) .Call(rnng_ctx_open, socket)
7563

76-
#' @rdname context
64+
#' Technical Utility: Open Context
65+
#'
66+
#' Open a new Context to be used with a Socket. This function is a performance
67+
#' variant of \code{\link{context}}, designed to wrap a socket in a function
68+
#' argument when calling \code{\link{request}} or \code{\link{reply}}.
69+
#'
70+
#' @param socket a Socket.
71+
#'
72+
#' @details External pointers created by this function are unclassed, hence
73+
#' methods for contexts such as \code{\link{close}} will not work. However
74+
#' they function as a Context would when passed to all messaging functions.
75+
#' The context is automatically closed when the object is garbage collected.
76+
#'
77+
#' @return An external pointer.
78+
#'
79+
#' @examples
80+
#' s <- socket("req", listen = "inproc://nanonext")
81+
#' r <- request(.context(s), "request data")
82+
#' close(s)
83+
#'
7784
#' @export
7885
#'
7986
.context <- function(socket) .Call(rnng_ctx_create, socket)

man/context.Rd

Lines changed: 1 addition & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/dot-context.Rd

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)