From b387153ca79272f8d6dc7298bae9fd2d800b524c Mon Sep 17 00:00:00 2001 From: shikokuchuo <53399081+shikokuchuo@users.noreply.github.com> Date: Wed, 25 Oct 2023 13:32:46 +0100 Subject: [PATCH] amend pipe_notify() defaults --- DESCRIPTION | 2 +- NEWS.md | 3 ++- R/sync.R | 13 +++++++------ man/pipe_notify.Rd | 13 +++++++------ tests/tests.R | 8 ++++---- 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index aa85005f1..ff7e9f641 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: nanonext Type: Package Title: NNG (Nanomsg Next Gen) Lightweight Messaging Library -Version: 0.10.2.9008 +Version: 0.10.2.9009 Description: R binding for NNG (Nanomsg Next Gen), a successor to ZeroMQ. NNG is a socket library providing high-performance scalability protocols, a cross-platform standard for messaging and communications. Serves as a diff --git a/NEWS.md b/NEWS.md index 6c749d1bb..ce92dacdb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# nanonext 0.10.2.9008 (development) +# nanonext 0.10.2.9009 (development) #### New Features @@ -9,6 +9,7 @@ * `lock()` supplying 'cv' has improved behaviour which locks the socket whilst allowing for both initial connections and re-connections (when the 'cv' is registered for both add and remove pipe events). * Improves listener / dialer logic for TLS connections, allowing *inter alia* synchronous dials. +* `pipe_notify()` arguments 'add', 'remove' and 'flag' now default to FALSE instead of TRUE for easier selective specification of the events to signal. * `request()` logical argument 'ack' removed as a method of synchronising with the rep node. * `strcat()` is deprecated and will be removed in a future package version (re-focusing on core functions). * Removes `weakref()`, `weakref_key()` and `weakref_value()`: please use equivalent functions from the `rlang` package instead. diff --git a/R/sync.R b/R/sync.R index 24e51a6c0..fdddcbcc0 100644 --- a/R/sync.R +++ b/R/sync.R @@ -160,13 +160,14 @@ cv_signal <- function(cv) invisible(.Call(rnng_cv_signal, cv)) #' @param cv2 [default NULL] optionally, if specified, a second 'conditionVariable' #' to signal. Note that this cv is signalled sequentially after the first #' condition variable. -#' @param add [default TRUE] logical value whether to signal when a pipe is added. -#' @param remove [default TRUE] logical value whether to signal when a pipe is +#' @param add [default FALSE] logical value whether to signal when a pipe is +#' added. +#' @param remove [default FALSE] logical value whether to signal when a pipe is #' removed. -#' @param flag [default TRUE] logical value whether to also set a flag in the +#' @param flag [default FALSE] logical value whether to also set a flag in the #' 'conditionVariable'. This can help distinguish between different types of -#' signal, and causes any subsequent \code{\link{wait}} or \code{\link{until}} -#' to return FALSE instead of TRUE. +#' signal, and causes any subsequent \code{\link{wait}} to return FALSE +#' instead of TRUE. #' #' @details For add: this event occurs after the pipe is fully added to the #' socket. Prior to this time, it is not possible to communicate over the @@ -201,7 +202,7 @@ cv_signal <- function(cv) invisible(.Call(rnng_cv_signal, cv)) #' #' @export #' -pipe_notify <- function(socket, cv, cv2 = NULL, add = TRUE, remove = TRUE, flag = TRUE) +pipe_notify <- function(socket, cv, cv2 = NULL, add = FALSE, remove = FALSE, flag = FALSE) invisible(.Call(rnng_pipe_notify, socket, cv, cv2, add, remove, flag)) #' Lock / Unlock a Socket diff --git a/man/pipe_notify.Rd b/man/pipe_notify.Rd index b6388045a..5bfe5d671 100644 --- a/man/pipe_notify.Rd +++ b/man/pipe_notify.Rd @@ -4,7 +4,7 @@ \alias{pipe_notify} \title{Pipe Notify} \usage{ -pipe_notify(socket, cv, cv2 = NULL, add = TRUE, remove = TRUE, flag = TRUE) +pipe_notify(socket, cv, cv2 = NULL, add = FALSE, remove = FALSE, flag = FALSE) } \arguments{ \item{socket}{a Socket.} @@ -15,15 +15,16 @@ pipe_notify(socket, cv, cv2 = NULL, add = TRUE, remove = TRUE, flag = TRUE) to signal. Note that this cv is signalled sequentially after the first condition variable.} -\item{add}{[default TRUE] logical value whether to signal when a pipe is added.} +\item{add}{[default FALSE] logical value whether to signal when a pipe is +added.} -\item{remove}{[default TRUE] logical value whether to signal when a pipe is +\item{remove}{[default FALSE] logical value whether to signal when a pipe is removed.} -\item{flag}{[default TRUE] logical value whether to also set a flag in the +\item{flag}{[default FALSE] logical value whether to also set a flag in the 'conditionVariable'. This can help distinguish between different types of -signal, and causes any subsequent \code{\link{wait}} or \code{\link{until}} -to return FALSE instead of TRUE.} +signal, and causes any subsequent \code{\link{wait}} to return FALSE +instead of TRUE.} } \value{ Invisibly, zero on success (will otherwise error). diff --git a/tests/tests.R b/tests/tests.R index 23659d99d..84c84572f 100644 --- a/tests/tests.R +++ b/tests/tests.R @@ -240,7 +240,7 @@ nanotestaio(cs <- request(.context(req$socket), data = TRUE, send_mode = "raw")) nanotest(recv(ctxn, mode = "logical", block = 500)) nanotestz(send(ctxn, TRUE, mode = 3L, block = 500)) nanotestz(reap(ctxn)) -nanotestz(pipe_notify(rep, cv)) +nanotestz(pipe_notify(rep, cv, add = TRUE, remove = TRUE, flag = TRUE)) nanotestz(pipe_notify(req$socket, cv = cv, add = FALSE, remove = TRUE, flag = FALSE)) nanotesterr(request_signal(err, "test", cv = cv), "valid") nanotesterr(recv_aio_signal(err, cv = cv, timeout = 500)) @@ -267,7 +267,7 @@ nanotestnano(pub <- nano("pub", listen = "inproc://ps")) nanotestnano(sub <- nano("sub", dial = "inproc://ps", autostart = NA)) nanotestxp(cv <- cv()) nanotestxp(cv2 <- cv()) -nanotestz(pipe_notify(pub$socket, cv, cv2, flag = FALSE)) +nanotestz(pipe_notify(pub$socket, cv, cv2, add = TRUE, remove = TRUE)) nanotestnano(sub$opt(name = "sub:prefnew", value = FALSE)) nanotest(!sub$opt(name = "sub:prefnew")) nanotesterr(sub$opt(name = "false", value = 100), "supported") @@ -293,7 +293,7 @@ nanotest(cv_value(cv) == 1L) nanotestnano(surv <- nano(protocol = "surveyor", listen = "inproc://sock1", dial = "inproc://sock2")) nanotestp(surv) nanotestnano(resp <- nano(protocol = "respondent", listen = "inproc://sock2", dial = "inproc://sock1")) -nanotestz(pipe_notify(surv$socket, cv, cv2, flag = TRUE)) +nanotestz(pipe_notify(surv$socket, cv, cv2, add = TRUE, remove = TRUE, flag = TRUE)) surv$dialer <- NULL nanotestxp(surv$dialer[[1L]]) nanotestxp(surv$listener[[1L]]) @@ -426,7 +426,7 @@ nanotestnn(recv(s1, block = 500)) nanotest(is_error_value(recv(s2))) nanotestz(unlock(s)) nanotesterr(unlock(cv), "valid Socket") -nanotestz(pipe_notify(s, cv = cv, flag = FALSE)) +nanotestz(pipe_notify(s, cv = cv, add = TRUE, remove = TRUE, flag = FALSE)) nanotestnano(s3 <- socket("bus", dial = "inproc://nanolock")) nanotestz(send(s, "test", block = 500)) nanotestnn(recv(s3, block = 500))