Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements event-driven promises capability through the aio callback mechanism #29

Merged
merged 10 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions 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.13.6.9000
Version: 0.13.6.9002
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 All @@ -26,10 +26,14 @@ License: GPL (>= 3)
BugReports: https://github.com/shikokuchuo/nanonext/issues
URL: https://shikokuchuo.net/nanonext/, https://github.com/shikokuchuo/nanonext/
Encoding: UTF-8
SystemRequirements: 'libnng' >= 1.5 and 'libmbedtls' >= 2.5, or 'cmake' to
SystemRequirements: 'libnng' >= 1.6 and 'libmbedtls' >= 2.5, or 'cmake' to
compile NNG and/or Mbed TLS included in package sources
Depends:
R (>= 3.5)
Imports:
later
LinkingTo:
later
Suggests:
knitr,
markdown
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export(recv_aio)
export(recv_aio_signal)
export(reply)
export(request)
export(request2)
export(request_signal)
export(send)
export(send_aio)
Expand All @@ -96,6 +97,7 @@ export(until_)
export(wait)
export(wait_)
export(write_cert)
importFrom(later,later)
importFrom(stats,start)
importFrom(tools,md5sum)
importFrom(utils,.DollarNames)
Expand Down
11 changes: 10 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# nanonext 0.13.6 (development)
# nanonext 0.13.6.9002 (development)

#### New Features

* Integrates with the `later` package to provide the foundation for truly event-driven (non-polling) promises (thanks @jcheng5 for the initial prototype in #28), where side-effects are enacted asynchronously upon aio completion.
* Adds `request2()` for creating a request that may be turned into an event-driven promise.

#### Updates

* Updates minimum 'libnng' version requirement to v1.6.0 (if a suitable system-installed version is not found, the bundled version is compiled from source).

# nanonext 0.13.6

Expand Down
18 changes: 18 additions & 0 deletions R/context.R
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,21 @@ request_signal <- function(context,
"integer", "logical", "numeric", "raw", "string"),
timeout = NULL)
data <- .Call(rnng_request_signal, context, data, cv, send_mode, recv_mode, timeout, environment())

#' Request2 (RPC Client for Req/Rep Protocol)
#'
#' \strong{request2} is the next generation request function that optionally
#' takes a condition variable for signalling, and supports event-driven
#' promises.
#'
#' @rdname request
#' @export
#'
request2 <- function(context,
data,
cv = NULL,
send_mode = c("serial", "raw", "next"),
recv_mode = c("serial", "character", "complex", "double",
"integer", "logical", "numeric", "raw", "string"),
timeout = NULL)
data <- .Call(rnng_request_promise, context, data, cv, send_mode, recv_mode, timeout, environment())
1 change: 1 addition & 0 deletions R/nanonext-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
#' @author Charlie Gao \email{charlie.gao@@shikokuchuo.net}
#' (\href{https://orcid.org/0000-0002-0750-061X}{ORCID})
#'
#' @importFrom later later
#' @importFrom stats start
#' @importFrom tools md5sum
#' @importFrom utils .DollarNames
Expand Down
3 changes: 2 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ vignette("nanonext", package = "nanonext")

#### Linux / Mac / Solaris

Installation from source requires 'libnng' >= v1.5.0 and 'libmbedtls' >= 2.5.0 (suitable installations are automatically detected), or else 'cmake' to compile 'libnng' v1.7.3 and 'libmbedtls' v3.6.0 LTS included within the package sources.
Installation from source requires 'libnng' >= v1.6.0 and 'libmbedtls' >= 2.5.0 (suitable installations are automatically detected), or else 'cmake' to compile 'libnng' v1.7.3 and 'libmbedtls' v3.6.0 LTS included within the package sources.

**It is recommended for optimal performance and stability to let the package automatically compile bundled versions of 'libmbedtls' and 'libnng' during installation.** To ensure the libraries are compiled from source even if system installations are present, set the `NANONEXT_LIBS` environment variable prior to installation e.g. by `Sys.setenv(NANONEXT_LIBS = 1)`.

Expand All @@ -169,6 +169,7 @@ We would like to acknowledge in particular:

- [Garrett D'Amore](https://github.com/gdamore), author of the NNG library, for generous advice and for implementing a feature request specifically for a more efficient 'aio' implementation in `nanonext`.
- The [R Consortium](https://www.r-consortium.org/) for funding the development of the secure TLS capabilities in the package, and [Henrik Bengtsson](https://github.com/HenrikBengtsson) and [Will Landau](https://github.com/wlandau/)'s roles in making this possible.
- [Joe Cheng](https://github.com/jcheng5/) for prototyping the integration of `nanonext` with `later` to support the next generation of completely event-driven promises in `mirai`.
- [R Core](https://www.r-project.org/contributors.html) for various auxiliary functions for serialisation and raw / character conversion, which have been adopted by the package.
- [Luke Tierney](https://github.com/ltierney/) and [Mike Cheng](https://github.com/coolbutuseless) for meticulous documentation of the R serialization mechanism, which led to the package's own implementation of a low-level interface to R serialization.
- [Jeroen Ooms](https://github.com/jeroen) - for his 'Anticonf (tm)' configure script, on which our original 'configure' was based, although much modified since.
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ vignette("nanonext", package = "nanonext")

#### Linux / Mac / Solaris

Installation from source requires ‘libnng’ \>= v1.5.0 and ‘libmbedtls’
Installation from source requires ‘libnng’ \>= v1.6.0 and ‘libmbedtls’
\>= 2.5.0 (suitable installations are automatically detected), or else
‘cmake’ to compile ‘libnng’ v1.7.3 and ‘libmbedtls’ v3.6.0 LTS included
within the package sources.
Expand Down Expand Up @@ -221,6 +221,9 @@ We would like to acknowledge in particular:
development of the secure TLS capabilities in the package, and [Henrik
Bengtsson](https://github.com/HenrikBengtsson) and [Will
Landau](https://github.com/wlandau/)’s roles in making this possible.
- [Joe Cheng](https://github.com/jcheng5/) for prototyping the
integration of `nanonext` with `later` to support the next generation
of completely event-driven promises in `mirai`.
- [R Core](https://www.r-project.org/contributors.html) for various
auxiliary functions for serialisation and raw / character conversion,
which have been adopted by the package.
Expand Down
4 changes: 2 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ fi

echo "#include <nng/nng.h>
int main() {
#if NNG_MAJOR_VERSION < 1 || NNG_MAJOR_VERSION == 1 && NNG_MINOR_VERSION < 5
#if NNG_MAJOR_VERSION < 1 || NNG_MAJOR_VERSION == 1 && NNG_MINOR_VERSION < 6
*(void *) 0 = 0;
#endif
}" | ${CC} ${NNG_CFLAGS} -xc - -o /dev/null > /dev/null 2>&1
Expand All @@ -140,7 +140,7 @@ fi

if [ $? -ne 0 ]
then
echo "No existing 'libnng' >= 1.5 found"
echo "No existing 'libnng' >= 1.6 found"
echo "Detecting 'cmake'..."
which cmake
if [ $? -ne 0 ]
Expand Down
15 changes: 15 additions & 0 deletions man/request.Rd

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

Loading
Loading