Skip to content

Commit a34b0b0

Browse files
committed
implements next serialisation stub
1 parent 1370dc3 commit a34b0b0

File tree

12 files changed

+51
-42
lines changed

12 files changed

+51
-42
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: nanonext
22
Type: Package
33
Title: NNG (Nanomsg Next Gen) Lightweight Messaging Library
4-
Version: 0.10.0.9010
4+
Version: 0.10.0.9011
55
Description: R binding for NNG (Nanomsg Next Gen), a successor to ZeroMQ. NNG is
66
a socket library providing high-performance scalability protocols, a
77
cross-platform standard for messaging and communications. Serves as a

NEWS.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
# nanonext 0.10.0.9010 (development)
1+
# nanonext 0.10.0.9011 (development)
22

33
#### New Features
44

5-
* `reap()` implemented as a faster alternative to `close()` for Sockets, Contexts, Listeners and Dialers - avoiding S3 method dispatch, hence works for unclassed external pointers created by `.context()`.
65
* `request()` adds logical argument 'ack', which sends an ack(nowledgement) back to the rep node upon a successful async message receive.
6+
* `reap()` implemented as a faster alternative to `close()` for Sockets, Contexts, Listeners and Dialers - avoiding S3 method dispatch, hence works for unclassed external pointers created by `.context()`.
7+
* `random()` updated to use the Mbed TLS library to generate random bytes. Adds a 'convert' argument for specifying whether to return a raw vector or character string.
8+
* Adds 'next' as a mode for send functions, as a 100% compatible R serialisation format.
79

810
#### Updates
911

10-
* `random()` updated to use the Mbed TLS library to generate random bytes. Adds a 'convert' argument for specifying whether to return a raw vector or character string.
1112
* `write_cert()` has been optimised for higher efficiency and faster operation.
13+
* `send()` and `recv()` over contexts now use more efficient synchronous methods where available.
1214
* Fixes package installation failures where the R default C compiler command contains additional flags (thanks @potash #16).
1315
* Performance improvements due to simplification of the internal structure of 'aio' objects.
1416
* Rolls forward bundled 'libnng' to v1.6.0 alpha (a54820f).

R/aio.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
#'
5656
#' @export
5757
#'
58-
send_aio <- function(con, data, mode = c("serial", "raw"), timeout = NULL)
58+
send_aio <- function(con, data, mode = c("serial", "raw", "next"), timeout = NULL)
5959
data <- .Call(rnng_send_aio, con, data, mode, timeout, environment())
6060

6161
#' Receive Async

R/context.R

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,13 @@ close.nanoContext <- function(con, ...) invisible(.Call(rnng_ctx_close, con))
101101
#' @param execute a function which takes the received (converted) data as its
102102
#' first argument. Can be an anonymous function of the form \code{function(x) do(x)}.
103103
#' Additional arguments can also be passed in through '...'.
104-
#' @param send_mode [default 'serial'] to send serialised R objects, or 'raw' to
105-
#' send atomic vectors of any type as a raw byte vector. Use 'serial' to
106-
#' ensure perfect reproducibility within R, although 'raw' must be used when
104+
#' @param send_mode [default 'serial'] one of 'serial' to send serialised R objects,
105+
#' 'raw' to send atomic vectors of any type as a raw byte vector, or 'next'
106+
#' to send in a new R-compatible serialisation format. Use 'serial' to ensure
107+
#' perfect reproducibility within R, although 'raw' must be used when
107108
#' interfacing with external applications which do not understand R
108109
#' serialisation. Alternatively, for performance, specify an integer position
109-
#' in the vector of choices i.e. 1L for 'serial' or 2L for 'raw'.
110+
#' in the vector of choices e.g. 1L for 'serial' or 2L for 'raw' etc.
110111
#' @param recv_mode [default 'serial'] mode of vector to be received - one of
111112
#' 'serial', 'character', 'complex', 'double', 'integer', 'logical',
112113
#' 'numeric', 'raw', or 'string'. The default 'serial' means a serialised R
@@ -159,7 +160,7 @@ reply <- function(context,
159160
execute,
160161
recv_mode = c("serial", "character", "complex", "double",
161162
"integer", "logical", "numeric", "raw"),
162-
send_mode = c("serial", "raw"),
163+
send_mode = c("serial", "raw", "next"),
163164
timeout = NULL,
164165
...) {
165166

@@ -224,7 +225,7 @@ reply <- function(context,
224225
#'
225226
request <- function(context,
226227
data,
227-
send_mode = c("serial", "raw"),
228+
send_mode = c("serial", "raw", "next"),
228229
recv_mode = c("serial", "character", "complex", "double",
229230
"integer", "logical", "numeric", "raw", "string"),
230231
timeout = NULL,
@@ -266,7 +267,7 @@ request <- function(context,
266267
request_signal <- function(context,
267268
data,
268269
cv,
269-
send_mode = c("serial", "raw"),
270+
send_mode = c("serial", "raw", "next"),
270271
recv_mode = c("serial", "character", "complex", "double",
271272
"integer", "logical", "numeric", "raw", "string"),
272273
timeout = NULL)

R/nano.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,19 +171,19 @@ nano <- function(protocol = c("bus", "pair", "push", "pull", "pub", "sub",
171171
}
172172

173173
nano[["recv"]] <- function(mode = c("serial", "character", "complex", "double",
174-
"integer", "logical", "numeric", "raw"),
174+
"integer", "logical", "numeric", "raw", "string"),
175175
block = NULL)
176176
recv(socket, mode = mode, block = block)
177177

178178
nano[["recv_aio"]] <- function(mode = c("serial", "character", "complex", "double",
179-
"integer", "logical", "numeric", "raw"),
179+
"integer", "logical", "numeric", "raw", "string"),
180180
timeout = NULL)
181181
recv_aio(socket, mode = mode, timeout = timeout)
182182

183-
nano[["send"]] <- function(data, mode = c("serial", "raw"), block = NULL)
183+
nano[["send"]] <- function(data, mode = c("serial", "raw", "next"), block = NULL)
184184
send(socket, data = data, mode = mode, block = block)
185185

186-
nano[["send_aio"]] <- function(data, mode = c("serial", "raw"), timeout = NULL)
186+
nano[["send_aio"]] <- function(data, mode = c("serial", "raw", "next"), timeout = NULL)
187187
send_aio(socket, data = data, mode = mode, timeout = timeout)
188188

189189
nano[["opt"]] <- function(name, value)

R/sendrecv.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@
2222
#'
2323
#' @param con a Socket, Context or Stream.
2424
#' @param data an object (a vector, if mode = 'raw').
25-
#' @param mode [default 'serial'] to send serialised R objects, or 'raw' to send
26-
#' atomic vectors of any type as a raw byte vector. For Streams, 'raw' is
25+
#' @param mode [default 'serial'] one of 'serial' to send serialised R objects,
26+
#' 'raw' to send atomic vectors of any type as a raw byte vector, or 'next'
27+
#' to send in a new R-compatible serialisation format. For Streams, 'raw' is
2728
#' the only option and this argument is ignored. Use 'serial' to ensure
2829
#' perfect reproducibility within R, although 'raw' must be used when
2930
#' interfacing with external applications which do not understand R
3031
#' serialisation. Alternatively, for performance, specify an integer position
31-
#' in the vector of choices i.e. 1L for 'serial' or 2L for 'raw'.
32+
#' in the vector of choices e.g. 1L for 'serial' or 2L for 'raw' etc.
3233
#' @param block [default NULL] which applies the connection default (see section
3334
#' 'Blocking' below). Specify logical TRUE to block until successful or FALSE
3435
#' to return immediately even if unsuccessful (e.g. if no connection is
@@ -77,7 +78,7 @@
7778
#'
7879
#' @export
7980
#'
80-
send <- function(con, data, mode = c("serial", "raw"), block = NULL)
81+
send <- function(con, data, mode = c("serial", "raw", "next"), block = NULL)
8182
.Call(rnng_send, con, data, mode, block)
8283

8384
#' Receive

man/reply.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/request.Rd

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

man/send.Rd

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

man/send_aio.Rd

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

0 commit comments

Comments
 (0)