Skip to content

Commit

Permalink
renames wait_aio() call_aio_safe()
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Nov 21, 2023
1 parent 735bb82 commit 2544d59
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 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.4.9005
Version: 0.10.4.9006
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 NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export(.until)
export(base64dec)
export(base64enc)
export(call_aio)
export(call_aio_safe)
export(context)
export(cv)
export(cv_reset)
Expand Down Expand Up @@ -98,7 +99,6 @@ export(unresolved)
export(unsubscribe)
export(until)
export(wait)
export(wait_aio)
export(write_cert)
importFrom(stats,start)
importFrom(utils,.DollarNames)
Expand Down
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# nanonext 0.10.4.9005 (development)
# nanonext 0.10.4.9006 (development)

#### New Features

* Introduces `wait_aio()`, a user-interruptible version of `call_aio()`.
* Introduces `call_aio_safe()`, a user-interruptible version of `call_aio()`, safe for interactive use.
* Implements `%~>%` signal forwarder from one 'conditionVariable' to another.

#### Updates
Expand Down
7 changes: 4 additions & 3 deletions R/aio.R
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ recv_aio_signal <- function(con,
#'
#' msg <- recv_aio(s2, timeout = 100)
#' msg
#' wait_aio(msg)$data
#' call_aio_safe(msg)$data
#'
#' close(s1)
#' close(s2)
Expand All @@ -221,12 +221,13 @@ call_aio <- function(aio) invisible(.Call(rnng_aio_call, aio))

#' Wait for the Value of an Asynchronous Aio Operation
#'
#' \code{wait_aio} is identical to \code{call_aio} but allows user interrupts.
#' \code{call_aio_safe} is identical to \code{call_aio} but allows user
#' interrupts, thus being safe for interactive use.
#'
#' @rdname call_aio
#' @export
#'
wait_aio <- function(aio) invisible(.Call(rnng_wait_thread_create, aio))
call_aio_safe <- function(aio) invisible(.Call(rnng_wait_thread_create, aio))

#' Stop Asynchronous Aio Operation
#'
Expand Down
9 changes: 5 additions & 4 deletions man/call_aio.Rd

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

10 changes: 5 additions & 5 deletions tests/tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ nanotesterr(msg$data, "active")
nanotest(identical(call_aio(n), n))
nanotestaio(sraio <- n$send_aio(as.raw(0L), mode = "r", timeout = 500))
nanotestaio(rraio <- n1$recv_aio(mode = 1L, timeout = 500))
nanotestw(is_nul_byte(wait_aio(rraio)$data))
nanotestw(is_nul_byte(call_aio_safe(rraio)$data))
nanotestaio(sraio <- n$send_aio(as.raw(1L), mode = "ra", timeout = 500))
nanotestaio(rraio <- n1$recv_aio(mode = "raw", timeout = 500))
nanotest(is.raw(call_aio(rraio)$data))
Expand Down Expand Up @@ -188,7 +188,7 @@ nanotesterr(req$opt("false", list()), "type")
nanotestnano(ctx <- context(rep))
nanotestp(ctx)
nanotestaio(csaio <- req$send_aio(data.frame(), mode = "seria", timeout = 500))
nanotest(is.integer(wait_aio(csaio)$result))
nanotest(is.integer(call_aio_safe(csaio)$result))
nanotestaio(craio <- recv_aio(ctx, timeout = 500))
nanotest(is.list(.subset2(call_aio(craio), "data")))
nanotest(is.integer(req$send("context test", mode ="raw", block = 500)))
Expand Down Expand Up @@ -341,7 +341,7 @@ nanotest(is.integer(call_aio(haio)$status))
haio <- ncurl_aio("https://trin.cam.ac.uk/", convert = FALSE, response = list("server"))
nanotest(is.integer(call_aio(haio)$status))
put1 <- ncurl_aio("http://postman-echo.com/put", method = "PUT", headers = c(Authorization = "Bearer token"), data = "test", response = c("date", "server"), timeout = 3000L)
nanotest(is.integer(wait_aio(put1)$status))
nanotest(is.integer(call_aio_safe(put1)$status))
nanotestnn(put1$headers)
nanotestnn(put1$data)
put2 <- ncurl_aio("http://postman-echo.com/put", method = "PUT", headers = list(Authorization = "Bearer token"), response = list("date", "server"), timeout = 3000L)
Expand Down Expand Up @@ -413,7 +413,7 @@ if (length(s)) {
nanotestn(stop_aio(ss))
nanotest(is.integer(send(s, 12.56, mode = "raw", block = 500L)))
nanotestaio(sr <- recv_aio_signal(s, mode = "double", timeout = 500L, cv = cv))
nanotestw(length(wait_aio(sr)[["data"]]))
nanotestw(length(call_aio_safe(sr)[["data"]]))
nanotest(cv_value(cv) > 0L)
nanotest(wait(cv))
nanotest(is.character(opt(s, "ws:request-headers")))
Expand Down Expand Up @@ -491,7 +491,7 @@ unres <- `class<-`(NA, "unresolvedValue")
nanotest(!unresolved(unres))
nanotestp(unres)
nanotest(identical(call_aio("a"), "a"))
nanotest(identical(wait_aio("a"), "a"))
nanotest(identical(call_aio_safe("a"), "a"))
nanotestn(stop_aio("a"))

nanotest(sha256("test") == "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08")
Expand Down

0 comments on commit 2544d59

Please sign in to comment.