From 2d05ebb55643ef33823e2b7361b3f4a282b263f0 Mon Sep 17 00:00:00 2001 From: shikokuchuo <53399081+shikokuchuo@users.noreply.github.com> Date: Sun, 1 Dec 2024 12:46:57 +0000 Subject: [PATCH] set value of interrupt explicitly rather than as a toggle --- DESCRIPTION | 2 +- NEWS.md | 2 +- R/sync.R | 16 ---------------- R/utils.R | 18 ++++++++++++++++++ man/dot-interrupt.Rd | 13 ++++++++----- src/init.c | 2 +- src/nanonext.h | 2 +- src/sync.c | 7 ------- src/utils.c | 11 +++++++++-- tests/tests.R | 4 ++-- 10 files changed, 41 insertions(+), 36 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 465b08af9..7feb9e848 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: nanonext Type: Package Title: NNG (Nanomsg Next Gen) Lightweight Messaging Library -Version: 1.3.2.9009 +Version: 1.3.2.9010 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 d77bf7ca8..863b0469d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# nanonext 1.3.2.9009 (development) +# nanonext 1.3.2.9010 (development) #### New Features diff --git a/R/sync.R b/R/sync.R index 559a49016..3f331a834 100644 --- a/R/sync.R +++ b/R/sync.R @@ -335,19 +335,3 @@ unlock <- function(socket) invisible(.Call(rnng_socket_unlock, socket)) #' @export #' .online <- function(sock) .Call(rnng_read_online, sock) - -#' Interrupt Switch -#' -#' Toggles on or off whether async receive completions trigger an interrupt. -#' Internal package function. -#' -#' @return NULL. -#' -#' @examples -#' .interrupt() -#' .interrupt() -#' -#' @keywords internal -#' @export -#' -.interrupt <- function() .Call(rnng_interrupt_switch) diff --git a/R/utils.R b/R/utils.R index 7016a028c..abfdb082b 100644 --- a/R/utils.R +++ b/R/utils.R @@ -347,6 +347,24 @@ serial_config <- function(class, sfunc, ufunc, vec = FALSE) #' .advance <- function() .Call(rnng_advance_rng_state) +#' Interrupt Switch +#' +#' Sets whether async receive completions trigger an interrupt. +#' Internal package function. +#' +#' @param x logical value. +#' +#' @return The logical value 'x' supplied. +#' +#' @examples +#' .interrupt() +#' .interrupt(FALSE) +#' +#' @keywords internal +#' @export +#' +.interrupt <- function(x = TRUE) .Call(rnng_interrupt_switch, x) + #' Internal Package Function #' #' Only present for cleaning up after running examples and tests. Do not attempt diff --git a/man/dot-interrupt.Rd b/man/dot-interrupt.Rd index 8b8dc120c..4d3f946fe 100644 --- a/man/dot-interrupt.Rd +++ b/man/dot-interrupt.Rd @@ -1,21 +1,24 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sync.R +% Please edit documentation in R/utils.R \name{.interrupt} \alias{.interrupt} \title{Interrupt Switch} \usage{ -.interrupt() +.interrupt(x = TRUE) +} +\arguments{ +\item{x}{logical value.} } \value{ -NULL. +The logical value 'x' supplied. } \description{ -Toggles on or off whether async receive completions trigger an interrupt. +Sets whether async receive completions trigger an interrupt. Internal package function. } \examples{ .interrupt() -.interrupt() +.interrupt(FALSE) } \keyword{internal} diff --git a/src/init.c b/src/init.c index 95ab48fa3..3205e650e 100644 --- a/src/init.c +++ b/src/init.c @@ -153,7 +153,7 @@ static const R_CallMethodDef callMethods[] = { {"rnng_eval_safe", (DL_FUNC) &rnng_eval_safe, 1}, {"rnng_fini", (DL_FUNC) &rnng_fini, 0}, {"rnng_get_opt", (DL_FUNC) &rnng_get_opt, 2}, - {"rnng_interrupt_switch", (DL_FUNC) &rnng_interrupt_switch, 0}, + {"rnng_interrupt_switch", (DL_FUNC) &rnng_interrupt_switch, 1}, {"rnng_is_error_value", (DL_FUNC) &rnng_is_error_value, 1}, {"rnng_is_nul_byte", (DL_FUNC) &rnng_is_nul_byte, 1}, {"rnng_listen", (DL_FUNC) &rnng_listen, 5}, diff --git a/src/nanonext.h b/src/nanonext.h index 7dbf7d416..3e1a1bd4a 100644 --- a/src/nanonext.h +++ b/src/nanonext.h @@ -336,7 +336,7 @@ SEXP rnng_dispatcher_socket(SEXP, SEXP, SEXP); SEXP rnng_eval_safe(SEXP); SEXP rnng_fini(void); SEXP rnng_get_opt(SEXP, SEXP); -SEXP rnng_interrupt_switch(void); +SEXP rnng_interrupt_switch(SEXP); SEXP rnng_is_error_value(SEXP); SEXP rnng_is_nul_byte(SEXP); SEXP rnng_listen(SEXP, SEXP, SEXP, SEXP, SEXP); diff --git a/src/sync.c b/src/sync.c index 24fa3e02f..03170ba8e 100644 --- a/src/sync.c +++ b/src/sync.c @@ -667,13 +667,6 @@ SEXP rnng_socket_unlock(SEXP socket) { } -SEXP rnng_interrupt_switch(void) { - - nano_interrupt = nano_interrupt ? 0 : 1; - return R_NilValue; - -} - // monitors -------------------------------------------------------------------- SEXP rnng_monitor_create(SEXP socket, SEXP cv) { diff --git a/src/utils.c b/src/utils.c index 817908836..9940fa19c 100644 --- a/src/utils.c +++ b/src/utils.c @@ -589,6 +589,8 @@ SEXP rnng_serial_config(SEXP klass, SEXP sfunc, SEXP ufunc, SEXP vec) { } +// specials -------------------------------------------------------------------- + SEXP rnng_set_marker(SEXP x) { special_bit = (uint8_t) NANO_INTEGER(x); @@ -596,8 +598,6 @@ SEXP rnng_set_marker(SEXP x) { } -// specials -------------------------------------------------------------------- - SEXP rnng_advance_rng_state(void) { GetRNGstate(); @@ -607,6 +607,13 @@ SEXP rnng_advance_rng_state(void) { } +SEXP rnng_interrupt_switch(SEXP x) { + + nano_interrupt = NANO_INTEGER(x); + return x; + +} + SEXP rnng_fini(void) { nng_fini(); diff --git a/tests/tests.R b/tests/tests.R index c6f97141e..a80cafaf0 100644 --- a/tests/tests.R +++ b/tests/tests.R @@ -559,8 +559,8 @@ test_true(!.mark(FALSE)) test_null(recv(disp, block = 500L)) test_zero(reap(s)) rm(disp) -test_null(.interrupt()) -test_null(.interrupt()) +test_true(.interrupt()) +test_true(!.interrupt(FALSE)) test_equal(nanonext:::.DollarNames.ncurlAio(NULL, "sta"), "status") test_equal(nanonext:::.DollarNames.recvAio(NULL, "dat"), "data")