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..f550b731b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,9 @@ -# nanonext 1.4.0.9000 (development) +# nanonext 1.4.0.9001 (development) #### Updates -* Removes partial matching from using `$`, `[[` or `[` on an object inheriting from class 'nano'. +* `reap()` now accepts an integer pipe ID to close the associated pipe. +* Removes partial matching when 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..b93fefa50 100644 --- a/R/messenger.R +++ b/R/messenger.R @@ -1,4 +1,4 @@ -# Copyright (C) 2022-2024 Hibiki AI Limited +# Copyright (C) 2022-2025 Hibiki AI Limited # # This file is part of nanonext. # @@ -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..22363d04c 100644 --- a/R/socket.R +++ b/R/socket.R @@ -1,4 +1,4 @@ -# Copyright (C) 2022-2024 Hibiki AI Limited +# Copyright (C) 2022-2025 Hibiki AI Limited # # This file is part of nanonext. # @@ -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..8f3a0fed9 100644 --- a/src/proto.c +++ b/src/proto.c @@ -1,4 +1,4 @@ -// Copyright (C) 2022-2024 Hibiki AI Limited +// Copyright (C) 2022-2025 Hibiki AI Limited // // This file is part of nanonext. // @@ -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; } diff --git a/tests/tests.R b/tests/tests.R index 87a3a85b1..8b840f753 100644 --- a/tests/tests.R +++ b/tests/tests.R @@ -384,6 +384,8 @@ test_zero(send_aio(poly, "one", timeout = 500, pipe = pipes[1L])[]) test_zero(send(poly, "two", block = 500, pipe = pipes[2L])) test_type("character", recv(poly1, block = 500)) test_type("character", recv(poly2, block = 500)) +test_zero(reap(pipes[1L])) +test_zero(reap(pipes[2L])) test_zero(reap(poly2)) test_zero(reap(poly1)) test_true(wait(cv))