Skip to content

Commit 1fb6abe

Browse files
committed
Update R interface for newly-added functions
1 parent 5725331 commit 1fb6abe

File tree

11 files changed

+45
-44
lines changed

11 files changed

+45
-44
lines changed

NAMESPACE

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,22 @@ S3method(unsubscribe,nanoSocket)
5353
export(.mirai_scm)
5454
export(call_aio)
5555
export(context)
56+
export(device)
5657
export(dial)
5758
export(is_aio)
5859
export(is_error_value)
5960
export(is_nano)
6061
export(is_nul_byte)
6162
export(listen)
63+
export(mclock)
6264
export(messenger)
65+
export(msleep)
6366
export(nano)
6467
export(nano_init)
6568
export(ncurl)
66-
export(nng_clock)
67-
export(nng_device)
6869
export(nng_error)
69-
export(nng_random)
70-
export(nng_sleep)
7170
export(nng_version)
71+
export(random)
7272
export(recv)
7373
export(recv_aio)
7474
export(reply)

NEWS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
#### New Features
44

5-
* Adds `nng_clock()`, `nng_sleep()` and `nng_random()` utilities exposing the library functions for timing and cryptographic RNG respectively.
6-
* `socket()` gains the ability to open 'raw' mode sockets. Please note: this is not for general use - do not set this argument unless you have a specific need, such as for use with `nng_device()` (refer to NNG documentation).
7-
* Implements `nng_device()` which creates a socket forwarder or proxy. Warning: use this in a separate process as this function blocks with no ability to interrupt.
5+
* Adds `mclock()`, `msleep()` and `random()` utilities exposing the library functions for timing and cryptographic RNG respectively.
6+
* `socket()` gains the ability to open 'raw' mode sockets. Please note: this is not for general use - do not set this argument unless you have a specific need, such as for use with `device()` (refer to NNG documentation).
7+
* Implements `device()` which creates a socket forwarder or proxy. Warning: use this in a separate process as this function blocks with no ability to interrupt.
88

99
# nanonext 0.5.1
1010

R/socket.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#' it is not generally possible to change these once started.
3737
#' @param raw [default FALSE] whether to open raw mode sockets. Note: not for
3838
#' general use - do not enable unless you have a specific need, such as for
39-
#' use with \code{\link{nng_device}} (refer to NNG documentation).
39+
#' use with \code{\link{device}} (refer to NNG documentation).
4040
#'
4141
#' @return A Socket (object of class 'nanoSocket' and 'nano').
4242
#'

R/utils.R

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ nng_version <- function() .Call(rnng_version)
9393
#'
9494
nng_error <- function(xc) .Call(rnng_strerror, xc)
9595

96-
#' NNG Clock Utility
96+
#' Clock Utility
9797
#'
9898
#' Provides the number of elapsed milliseconds since an arbitrary reference time
9999
#' in the past. The reference time will be the same for a given program, but
@@ -107,17 +107,17 @@ nng_error <- function(xc) .Call(rnng_strerror, xc)
107107
#' @return A double.
108108
#'
109109
#' @examples
110-
#' time <- nng_clock(); nng_sleep(100); nng_clock() - time
110+
#' time <- mclock(); msleep(100); mclock() - time
111111
#'
112112
#' @export
113113
#'
114-
nng_clock <- function() {
114+
mclock <- function() {
115115

116116
.Call(rnng_clock)
117117

118118
}
119119

120-
#' NNG Sleep Utility
120+
#' Sleep Utility
121121
#'
122122
#' Sleep function. May block for longer than requested, with the actual wait
123123
#' time determined by the capabilities of the underlying system.
@@ -127,11 +127,11 @@ nng_clock <- function() {
127127
#' @return Invisible NULL.
128128
#'
129129
#' @examples
130-
#' time <- nng_clock(); nng_sleep(100); nng_clock() - time
130+
#' time <- mclock(); msleep(100); mclock() - time
131131
#'
132132
#' @export
133133
#'
134-
nng_sleep <- function(msec) {
134+
msleep <- function(msec) {
135135

136136
invisible(.Call(rnng_sleep, msec))
137137

@@ -148,25 +148,26 @@ nng_sleep <- function(msec) {
148148
#' @return A (positive) double.
149149
#'
150150
#' @examples
151-
#' nng_random()
151+
#' random()
152152
#'
153153
#' @export
154154
#'
155-
nng_random <- function() {
155+
random <- function() {
156156

157157
.Call(rnng_random)
158158

159159
}
160160

161-
#' Create NNG Device
161+
#' Create Device
162162
#'
163163
#' Creates a device which is a socket forwarder or proxy. Provides for improved
164164
#' horizontal scalability, reliability, and isolation.
165165
#'
166166
#' @param s1 a raw mode Socket.
167167
#' @param s2 a raw mode Socket.
168168
#'
169-
#' @return This function does not return.
169+
#' @return Invisibly, an integer exit code. If the device was successfully
170+
#' created, this function does not return.
170171
#'
171172
#' @details Only raw mode sockets may be used with this function. Sockets s1 and
172173
#' s2 must be compatible with each other, i.e. be opposite halves of a two
@@ -180,7 +181,7 @@ nng_random <- function() {
180181
#'
181182
#' @export
182183
#'
183-
nng_device <- function(s1, s2) {
184+
device <- function(s1, s2) {
184185

185186
invisible(.Call(rnng_device, s1, s2))
186187

man/nng_device.Rd renamed to man/device.Rd

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

man/nng_clock.Rd renamed to man/mclock.Rd

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

man/nng_sleep.Rd renamed to man/msleep.Rd

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

man/nng_random.Rd renamed to man/random.Rd

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

man/socket.Rd

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

src/utils.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,7 @@ SEXP rnng_device(SEXP s1, SEXP s2) {
624624
*(nng_socket *) R_ExternalPtrAddr(s2));
625625
if (xc)
626626
return mk_error(xc);
627-
628-
return Rf_ScalarInteger(0);
627+
return Rf_ScalarInteger(xc);
629628

630629
}
631630

0 commit comments

Comments
 (0)