From 0ebcdf2440c10c1d7df32990e67581c1139be748 Mon Sep 17 00:00:00 2001 From: shikokuchuo <53399081+shikokuchuo@users.noreply.github.com> Date: Wed, 8 Jan 2025 20:17:08 +0000 Subject: [PATCH] pipe close concept --- DESCRIPTION | 2 +- NEWS.md | 3 ++- R/messenger.R | 2 +- R/socket.R | 2 +- man/reap.Rd | 2 +- src/proto.c | 5 +++++ 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b056909d1..ef3769021 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: nanonext Type: Package Title: NNG (Nanomsg Next Gen) Lightweight Messaging Library -Version: 1.4.0.9000 +Version: 1.4.0.9001 Description: R binding for NNG (Nanomsg Next Gen), a successor to ZeroMQ. NNG is a socket library implementing 'Scalability Protocols', a reliable, high-performance standard for common communications patterns including diff --git a/NEWS.md b/NEWS.md index 380eec33c..ec6b76be5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,8 @@ -# nanonext 1.4.0.9000 (development) +# nanonext 1.4.0.9001 (development) #### Updates +* `reap()` now accepts an integer pipe ID to close the associated pipe. * Removes partial matching from using `$`, `[[` or `[` on an object inheriting from class 'nano'. # nanonext 1.4.0 diff --git a/R/messenger.R b/R/messenger.R index 97546fd8e..364382c4d 100644 --- a/R/messenger.R +++ b/R/messenger.R @@ -60,7 +60,7 @@ messenger <- function(url, auth = NULL) { sock <- .Call(rnng_messenger, url) on.exit(expr = { send(sock, data = writeBin(":d ", raw()), mode = 2L, block = FALSE) - .Call(rnng_close, sock) + close(sock) }) cat("\n", file = stdout()) intro <- unlist(strsplit("nanonext messenger", "")) diff --git a/R/socket.R b/R/socket.R index c035bd58e..b6f9661a8 100644 --- a/R/socket.R +++ b/R/socket.R @@ -168,7 +168,7 @@ close.nanoSocket <- function(con, ...) invisible(.Call(rnng_close, con)) #' \code{\link{.context}}. Returns silently and does not warn or error, nor does #' it update the state of object attributes. #' -#' @param con a Socket, Context, Listener, Dialer or Pipe. +#' @param con a Socket, Context, Listener, Dialer or integer pipe ID. #' #' @return An integer exit code (zero on success). #' diff --git a/man/reap.Rd b/man/reap.Rd index 30fa9adc1..7aa9e3971 100644 --- a/man/reap.Rd +++ b/man/reap.Rd @@ -7,7 +7,7 @@ reap(con) } \arguments{ -\item{con}{a Socket, Context, Listener, Dialer or Pipe.} +\item{con}{a Socket, Context, Listener, Dialer or integer pipe ID.} } \value{ An integer exit code (zero on success). diff --git a/src/proto.c b/src/proto.c index 6ac85ec38..db681fc31 100644 --- a/src/proto.c +++ b/src/proto.c @@ -195,6 +195,11 @@ SEXP rnng_reap(SEXP con) { } else if (ptrtag == nano_DialerSymbol) { xc = nng_dialer_close(*(nng_dialer *) NANO_PTR(con)); + } else if (TYPEOF(con) == INTSXP) { + nng_pipe p; + p.id = (uint32_t) NANO_INTEGER(con); + xc = nng_pipe_close(p); + } else { xc = 3; }