@@ -16,8 +16,54 @@ static void nano_load_later(void) {
1616
1717}
1818
19+ static inline SEXP nano_PreserveObject (const SEXP x ) {
20+
21+ SEXP tail = CDR (nano_precious );
22+ SEXP node = Rf_cons (nano_precious , tail );
23+ SETCDR (nano_precious , node );
24+ if (tail != R_NilValue )
25+ SETCAR (tail , node );
26+ SET_TAG (node , x );
27+
28+ return node ;
29+
30+ }
31+
32+ static inline void nano_ReleaseObject (SEXP node ) {
33+
34+ SET_TAG (node , R_NilValue );
35+ SEXP head = CAR (node );
36+ SEXP tail = CDR (node );
37+ SETCDR (head , tail );
38+ if (tail != R_NilValue )
39+ SETCAR (tail , head );
40+
41+ }
42+
1943// aio completion callbacks ----------------------------------------------------
2044
45+
46+ void raio_invoke_cb (void * arg ) {
47+
48+ SEXP call , node = (SEXP ) arg , x = TAG (node );
49+ PROTECT (call = Rf_lcons (nano_ResolveSymbol , Rf_cons (nano_aio_get_msg (x ), R_NilValue )));
50+ Rf_eval (call , NANO_ENCLOS (x ));
51+ UNPROTECT (1 );
52+ nano_ReleaseObject (node );
53+
54+ }
55+
56+ void haio_invoke_cb (void * arg ) {
57+
58+ SEXP call , status , node = (SEXP ) arg , x = TAG (node );
59+ status = nano_aio_http_status (x );
60+ PROTECT (call = Rf_lcons (nano_ResolveSymbol , Rf_cons (status , R_NilValue )));
61+ Rf_eval (call , NANO_ENCLOS (x ));
62+ UNPROTECT (1 );
63+ nano_ReleaseObject (node );
64+
65+ }
66+
2167static void sendaio_complete (void * arg ) {
2268
2369 nng_aio * aio = ((nano_saio * ) arg )-> aio ;
0 commit comments