Skip to content

Commit

Permalink
amend pipe_notify() defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Oct 25, 2023
1 parent efa322f commit b387153
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# nanonext 0.10.2.9008 (development)
# nanonext 0.10.2.9009 (development)

#### New Features

Expand All @@ -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.
Expand Down
13 changes: 7 additions & 6 deletions R/sync.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions man/pipe_notify.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tests/tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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")
Expand All @@ -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]])
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit b387153

Please sign in to comment.