Skip to content

Commit

Permalink
set value of interrupt explicitly rather than as a toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Dec 1, 2024
1 parent 72efbda commit 2d05ebb
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 36 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: 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
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# nanonext 1.3.2.9009 (development)
# nanonext 1.3.2.9010 (development)

#### New Features

Expand Down
16 changes: 0 additions & 16 deletions R/sync.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
18 changes: 18 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions man/dot-interrupt.Rd

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

2 changes: 1 addition & 1 deletion src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion src/nanonext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 0 additions & 7 deletions src/sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 9 additions & 2 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,15 +589,15 @@ 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);
return x;

}

// specials --------------------------------------------------------------------

SEXP rnng_advance_rng_state(void) {

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

0 comments on commit 2d05ebb

Please sign in to comment.