diff --git a/DESCRIPTION b/DESCRIPTION index fc3f85077..06c3155d5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 @@ -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 diff --git a/NAMESPACE b/NAMESPACE index a9f83b67f..f66fa746b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) @@ -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) diff --git a/NEWS.md b/NEWS.md index 032f74ee3..4aeb74dd6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/R/context.R b/R/context.R index 0a70df53d..6aa92551d 100644 --- a/R/context.R +++ b/R/context.R @@ -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()) diff --git a/R/nanonext-package.R b/R/nanonext-package.R index fff6f714a..c5cf6c148 100644 --- a/R/nanonext-package.R +++ b/R/nanonext-package.R @@ -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 diff --git a/README.Rmd b/README.Rmd index 381fba95f..55312b09c 100644 --- a/README.Rmd +++ b/README.Rmd @@ -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)`. @@ -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. diff --git a/README.md b/README.md index 7533e483d..995103e9f 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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. diff --git a/configure b/configure index 88a9e1be4..5c8ab0809 100755 --- a/configure +++ b/configure @@ -128,7 +128,7 @@ fi echo "#include 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 @@ -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 ] diff --git a/man/request.Rd b/man/request.Rd index dccf3fca7..c1c1c475c 100644 --- a/man/request.Rd +++ b/man/request.Rd @@ -3,6 +3,7 @@ \name{request} \alias{request} \alias{request_signal} +\alias{request2} \title{Request over Context (RPC Client for Req/Rep Protocol)} \usage{ request( @@ -23,6 +24,16 @@ request_signal( "numeric", "raw", "string"), timeout = NULL ) + +request2( + context, + data, + cv = NULL, + send_mode = c("serial", "raw", "next"), + recv_mode = c("serial", "character", "complex", "double", "integer", "logical", + "numeric", "raw", "string"), + timeout = NULL +) } \arguments{ \item{context}{a Context.} @@ -57,6 +68,10 @@ Implements a caller/client for the req node of the req/rep protocol. Sends A signalling version of the function takes a 'conditionVariable' as an additional argument and signals it when the async receive is complete. + +\strong{request2} is the next generation request function that optionally + takes a condition variable for signalling, and supports event-driven + promises. } \details{ Sending the request and receiving the result are both performed diff --git a/src/aio.c b/src/aio.c index 97606f517..d8dc8b2a1 100644 --- a/src/aio.c +++ b/src/aio.c @@ -20,6 +20,7 @@ #define NANONEXT_SUPPLEMENTALS #define NANONEXT_SIGNALS #include "nanonext.h" +#include "later_shim.h" // internals ------------------------------------------------------------------- @@ -159,14 +160,7 @@ static void saio_complete(void *arg) { const int res = nng_aio_result(saio->aio); if (res) nng_msg_free(nng_aio_get_msg(saio->aio)); - -#ifdef NANONEXT_LEGACY_NNG - nng_mtx_lock(shr_mtx); - saio->result = res - !res; - nng_mtx_unlock(shr_mtx); -#else saio->result = res - !res; -#endif } @@ -184,14 +178,7 @@ static void isaio_complete(void *arg) { const int res = nng_aio_result(iaio->aio); if (iaio->data != NULL) R_Free(iaio->data); - -#ifdef NANONEXT_LEGACY_NNG - nng_mtx_lock(shr_mtx); iaio->result = res - !res; - nng_mtx_unlock(shr_mtx); -#else - iaio->result = res - !res; -#endif } @@ -202,13 +189,7 @@ static void raio_complete(void *arg) { if (res == 0) raio->data = nng_aio_get_msg(raio->aio); -#ifdef NANONEXT_LEGACY_NNG - nng_mtx_lock(shr_mtx); - raio->result = res - !res; - nng_mtx_unlock(shr_mtx); -#else raio->result = res - !res; -#endif } @@ -251,18 +232,57 @@ static void request_complete_signal(void *arg) { } +static void raio_invoke_cb(void *arg) { + SEXP call, cb = (SEXP) arg; + PROTECT(call = Rf_lcons(cb, R_NilValue)); + (void) Rf_eval(call, R_GlobalEnv); + UNPROTECT(1); +} + +static void raio_complete_cb(void *arg) { + + nano_aio *raio = (nano_aio *) arg; + const int res = nng_aio_result(raio->aio); + if (res == 0) + raio->data = nng_aio_get_msg(raio->aio); + raio->result = res - !res; + + nano_aio *saio = (nano_aio *) raio->next; + SEXP ax = CADR(ATTRIB((SEXP) saio->data)); + if (ax != R_NilValue) + later2(raio_invoke_cb, ax, 0); + +} + +static void request_complete_cb(void *arg) { + + nano_aio *raio = (nano_aio *) arg; + nano_aio *saio = (nano_aio *) raio->next; + nano_cv *ncv = (nano_cv *) saio->next; + nng_cv *cv = ncv->cv; + nng_mtx *mtx = ncv->mtx; + + const int res = nng_aio_result(raio->aio); + if (res == 0) + raio->data = nng_aio_get_msg(raio->aio); + + nng_mtx_lock(mtx); + raio->result = res - !res; + ncv->condition++; + nng_cv_wake(cv); + nng_mtx_unlock(mtx); + + SEXP ax = CADR(ATTRIB((SEXP) saio->data)); + if (ax != R_NilValue) + later2(raio_invoke_cb, ax, 0); + +} + static void iraio_complete(void *arg) { nano_aio *iaio = (nano_aio *) arg; const int res = nng_aio_result(iaio->aio); - -#ifdef NANONEXT_LEGACY_NNG - nng_mtx_lock(shr_mtx); - iaio->result = res - !res; - nng_mtx_unlock(shr_mtx); -#else iaio->result = res - !res; -#endif } @@ -310,13 +330,12 @@ static void request_finalizer(SEXP xptr) { if (R_ExternalPtrAddr(xptr) == NULL) return; nano_aio *xp = (nano_aio *) R_ExternalPtrAddr(xptr); nano_aio *saio = (nano_aio *) xp->next; -#ifdef NANONEXT_LEGACY_NNG - nng_ctx_close(*(nng_ctx *) saio->data); -#endif nng_aio_free(saio->aio); nng_aio_free(xp->aio); if (xp->data != NULL) nng_msg_free((nng_msg *) xp->data); + if (saio->data != NULL) + R_ReleaseObject((SEXP) saio->data); R_Free(saio); R_Free(xp); @@ -390,15 +409,7 @@ SEXP rnng_aio_result(SEXP env) { nano_aio *saio = (nano_aio *) R_ExternalPtrAddr(aio); -#ifdef NANONEXT_LEGACY_NNG - int res; - nng_mtx_lock(shr_mtx); - res = saio->result; - nng_mtx_unlock(shr_mtx); - if (res == 0) -#else if (nng_aio_busy(saio->aio)) -#endif return nano_unresolved; if (saio->result > 0) @@ -422,15 +433,7 @@ SEXP rnng_aio_get_msg(SEXP env) { nano_aio *raio = (nano_aio *) R_ExternalPtrAddr(aio); -#ifdef NANONEXT_LEGACY_NNG - int res; - nng_mtx_lock(shr_mtx); - res = raio->result; - nng_mtx_unlock(shr_mtx); - if (res == 0) -#else if (nng_aio_busy(raio->aio)) -#endif return nano_unresolved; if (raio->result > 0) @@ -595,15 +598,7 @@ SEXP rnng_unresolved2(SEXP aio) { nano_aio *aiop = (nano_aio *) R_ExternalPtrAddr(coreaio); -#ifdef NANONEXT_LEGACY_NNG - int res; - nng_mtx_lock(shr_mtx); - res = aiop->result; - nng_mtx_unlock(shr_mtx); - return Rf_ScalarLogical(!res); -#else return Rf_ScalarLogical(nng_aio_busy(aiop->aio)); -#endif } @@ -947,15 +942,7 @@ SEXP rnng_aio_http(SEXP env, SEXP response, SEXP type) { nano_aio *haio = (nano_aio *) R_ExternalPtrAddr(aio); -#ifdef NANONEXT_LEGACY_NNG - int res; - nng_mtx_lock(shr_mtx); - res = haio->result; - nng_mtx_unlock(shr_mtx); - if (res == 0) -#else if (nng_aio_busy(haio->aio)) -#endif return nano_unresolved; if (haio->result > 0) @@ -1212,7 +1199,8 @@ SEXP rnng_ncurl_session_close(SEXP session) { // request --------------------------------------------------------------------- SEXP rnng_request_impl(const SEXP con, const SEXP data, const SEXP sendmode, - const SEXP recvmode, const SEXP timeout, const SEXP clo, nano_cv *ncv) { + const SEXP recvmode, const SEXP timeout, const SEXP clo, + nano_cv *ncv, const int promises) { const nng_duration dur = timeout == R_NilValue ? NNG_DURATION_DEFAULT : (nng_duration) Rf_asInteger(timeout); const int mod = nano_matcharg(recvmode); @@ -1234,9 +1222,6 @@ SEXP rnng_request_impl(const SEXP con, const SEXP data, const SEXP sendmode, } saio = R_Calloc(1, nano_aio); -#ifdef NANONEXT_LEGACY_NNG - saio->data = ctx; -#endif saio->next = ncv; if ((xc = nng_msg_alloc(&msg, 0))) @@ -1252,11 +1237,20 @@ SEXP rnng_request_impl(const SEXP con, const SEXP data, const SEXP sendmode, nng_ctx_send(*ctx, saio->aio); raio = R_Calloc(1, nano_aio); + PROTECT(env = Rf_allocSExp(ENVSXP)); raio->type = RECVAIO; raio->mode = mod; raio->next = saio; + if (promises) { + R_PreserveObject(env); + saio->data = env; + } - if ((xc = nng_aio_alloc(&raio->aio, signal ? request_complete_signal : raio_complete, raio))) + if ((xc = nng_aio_alloc(&raio->aio, + promises ? + (signal ? request_complete_cb : raio_complete_cb) : + (signal ? request_complete_signal : raio_complete), + raio))) goto exitlevel2; nng_aio_set_timeout(raio->aio, dur); @@ -1266,7 +1260,6 @@ SEXP rnng_request_impl(const SEXP con, const SEXP data, const SEXP sendmode, PROTECT(aio = R_MakeExternalPtr(raio, nano_AioSymbol, R_NilValue)); R_RegisterCFinalizerEx(aio, request_finalizer, TRUE); - PROTECT(env = Rf_allocSExp(ENVSXP)); NANO_CLASS(env, "recvAio"); Rf_defineVar(nano_AioSymbol, aio, env); @@ -1280,6 +1273,7 @@ SEXP rnng_request_impl(const SEXP con, const SEXP data, const SEXP sendmode, return env; exitlevel2: + UNPROTECT(1); R_Free(raio); nng_aio_free(saio->aio); exitlevel1: @@ -1294,7 +1288,7 @@ SEXP rnng_request(SEXP con, SEXP data, SEXP sendmode, SEXP recvmode, SEXP timeou if (R_ExternalPtrTag(con) != nano_ContextSymbol) Rf_error("'con' is not a valid Context"); - return rnng_request_impl(con, data, sendmode, recvmode, timeout, clo, NULL); + return rnng_request_impl(con, data, sendmode, recvmode, timeout, clo, NULL, 0); } @@ -1306,7 +1300,18 @@ SEXP rnng_request_signal(SEXP con, SEXP data, SEXP cvar, SEXP sendmode, SEXP rec Rf_error("'cv' is not a valid Condition Variable"); nano_cv *ncv = (nano_cv *) R_ExternalPtrAddr(cvar); - return rnng_request_impl(con, data, sendmode, recvmode, timeout, clo, ncv); + return rnng_request_impl(con, data, sendmode, recvmode, timeout, clo, ncv, 0); + +} + +SEXP rnng_request_promise(SEXP con, SEXP data, SEXP cvar, SEXP sendmode, SEXP recvmode, SEXP timeout, SEXP clo) { + + if (R_ExternalPtrTag(con) != nano_ContextSymbol) + Rf_error("'con' is not a valid Context"); + + nano_cv *ncv = R_ExternalPtrTag(cvar) == nano_CvSymbol ? (nano_cv *) R_ExternalPtrAddr(cvar) : NULL; + + return rnng_request_impl(con, data, sendmode, recvmode, timeout, clo, ncv, 1); } diff --git a/src/core.c b/src/core.c index c6723da7b..73d44abcb 100644 --- a/src/core.c +++ b/src/core.c @@ -47,7 +47,8 @@ static SEXP eval_safe (void *call) { } static void rl_reset(void *data, Rboolean jump) { - if (jump && data == NULL) + (void) data; + if (jump) SET_TAG(nano_refHook, R_NilValue); } @@ -982,30 +983,6 @@ SEXP rnng_send(SEXP con, SEXP data, SEXP mode, SEXP block) { nng_ctx *ctxp = (nng_ctx *) R_ExternalPtrAddr(con); nng_msg *msgp; -#ifdef NANONEXT_LEGACY_NNG - - nng_aio *aiop; - - if ((xc = nng_msg_alloc(&msgp, 0))) - goto exitlevel1; - - if ((xc = nng_msg_append(msgp, buf.buf, buf.cur)) || - (xc = nng_aio_alloc(&aiop, NULL, NULL))) { - nng_msg_free(msgp); - goto exitlevel1; - } - - nng_aio_set_msg(aiop, msgp); - nng_aio_set_timeout(aiop, flags < 0 ? 0 : flags > 0 ? flags : (*NANO_INTEGER(block) == 1) * NNG_DURATION_DEFAULT); - nng_ctx_send(*ctxp, aiop); - NANO_FREE(buf); - nng_aio_wait(aiop); - if ((xc = nng_aio_result(aiop))) - nng_msg_free(nng_aio_get_msg(aiop)); - nng_aio_free(aiop); - -#else - if (flags <= 0) { if ((xc = nng_msg_alloc(&msgp, 0))) @@ -1043,8 +1020,6 @@ SEXP rnng_send(SEXP con, SEXP data, SEXP mode, SEXP block) { } -#endif - } else if (ptrtag == nano_StreamSymbol) { nano_encode(&buf, data); @@ -1136,30 +1111,6 @@ SEXP rnng_recv(SEXP con, SEXP mode, SEXP block, SEXP bytes) { nng_ctx *ctxp = (nng_ctx *) R_ExternalPtrAddr(con); nng_msg *msgp; -#ifdef NANONEXT_LEGACY_NNG - - nng_aio *aiop; - - if ((xc = nng_aio_alloc(&aiop, NULL, NULL))) - goto exitlevel1; - nng_aio_set_timeout(aiop, flags < 0 ? 0 : flags > 0 ? flags : (*NANO_INTEGER(block) == 1) * NNG_DURATION_DEFAULT); - nng_ctx_recv(*ctxp, aiop); - - nng_aio_wait(aiop); - if ((xc = nng_aio_result(aiop))) { - nng_aio_free(aiop); - goto exitlevel1; - } - - msgp = nng_aio_get_msg(aiop); - nng_aio_free(aiop); - buf = nng_msg_body(msgp); - sz = nng_msg_len(msgp); - res = nano_decode(buf, sz, mod); - nng_msg_free(msgp); - -#else - if (flags <= 0) { xc = nng_ctx_recvmsg(*ctxp, &msgp, (flags < 0 || *NANO_INTEGER(block) != 1) * NNG_FLAG_NONBLOCK); @@ -1195,8 +1146,6 @@ SEXP rnng_recv(SEXP con, SEXP mode, SEXP block, SEXP bytes) { } -#endif - } else if (ptrtag == nano_StreamSymbol) { mod = nano_matchargs(mode); diff --git a/src/init.c b/src/init.c index 9bf9645f0..b2d4c26c0 100644 --- a/src/init.c +++ b/src/init.c @@ -50,10 +50,6 @@ SEXP nano_refHook; SEXP nano_success; SEXP nano_unresolved; -#ifdef NANONEXT_LEGACY_NNG -nng_mtx *shr_mtx; -#endif - static void RegisterSymbols(void) { nano_AioSymbol = Rf_install("aio"); nano_ContextSymbol = Rf_install("context"); @@ -158,6 +154,7 @@ static const R_CallMethodDef callMethods[] = { {"rnng_recv_aio", (DL_FUNC) &rnng_recv_aio, 5}, {"rnng_recv_aio_signal", (DL_FUNC) &rnng_recv_aio_signal, 6}, {"rnng_request", (DL_FUNC) &rnng_request, 6}, + {"rnng_request_promise", (DL_FUNC) &rnng_request_promise, 7}, {"rnng_request_signal", (DL_FUNC) &rnng_request_signal, 7}, {"rnng_send", (DL_FUNC) &rnng_send, 4}, {"rnng_send_aio", (DL_FUNC) &rnng_send_aio, 5}, @@ -192,9 +189,6 @@ static const R_ExternalMethodDef externalMethods[] = { void attribute_visible R_init_nanonext(DllInfo* dll) { RegisterSymbols(); PreserveObjects(); -#ifdef NANONEXT_LEGACY_NNG - nng_mtx_alloc(&shr_mtx); -#endif R_registerRoutines(dll, NULL, callMethods, NULL, externalMethods); R_useDynamicSymbols(dll, FALSE); R_forceSymbols(dll, TRUE); @@ -202,7 +196,4 @@ void attribute_visible R_init_nanonext(DllInfo* dll) { void attribute_visible R_unload_nanonext(DllInfo *info) { ReleaseObjects(); -#ifdef NANONEXT_LEGACY_NNG - nng_mtx_free(shr_mtx); -#endif } diff --git a/src/later_shim.cpp b/src/later_shim.cpp new file mode 100644 index 000000000..62e90e173 --- /dev/null +++ b/src/later_shim.cpp @@ -0,0 +1,5 @@ +#include + +extern "C" void later2(void (*func)(void*), void* data, double secs) { + later::later(func, data, secs); +} diff --git a/src/later_shim.h b/src/later_shim.h new file mode 100644 index 000000000..7a9345b47 --- /dev/null +++ b/src/later_shim.h @@ -0,0 +1,7 @@ +#ifndef LATER_SHIM_H +#define LATER_SHIM_H + +// This is simply a shim so that later::later can be accessed from C, not C++ +void later2(void (*func)(void*), void* data, double secs); + +#endif diff --git a/src/nanonext.h b/src/nanonext.h index 74c43e633..566ac8028 100644 --- a/src/nanonext.h +++ b/src/nanonext.h @@ -21,10 +21,6 @@ #include -#if NNG_MAJOR_VERSION == 1 && NNG_MINOR_VERSION < 6 -#define NANONEXT_LEGACY_NNG -#endif - #ifdef NANONEXT_PROTOCOLS #include #include @@ -45,9 +41,6 @@ #ifdef NANONEXT_SUPPLEMENTALS #include #include -#ifdef NANONEXT_LEGACY_NNG -extern nng_mtx *shr_mtx; -#endif typedef struct nano_listener_s { nng_listener list; @@ -253,6 +246,7 @@ SEXP rnng_recv(SEXP, SEXP, SEXP, SEXP); SEXP rnng_recv_aio(SEXP, SEXP, SEXP, SEXP, SEXP); SEXP rnng_recv_aio_signal(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); SEXP rnng_request(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +SEXP rnng_request_promise(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); SEXP rnng_request_signal(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); SEXP rnng_send(SEXP, SEXP, SEXP, SEXP); SEXP rnng_send_aio(SEXP, SEXP, SEXP, SEXP, SEXP);