@@ -120,8 +120,8 @@ recv_aio <- function(con,
120120 n = 65536L )
121121 data <- .Call(rnng_recv_aio , con , mode , timeout , n , environment(),
122122 function () {
123- cb <- data $ callback
124- if (! is.null (cb )) {
123+ cb <- .subset2( data , " callback" )
124+ if (is.function (cb )) {
125125 cb(data )
126126 }
127127 }
@@ -166,8 +166,8 @@ recv_aio_signal <- function(con,
166166 n = 65536L )
167167 data <- .Call(rnng_recv_aio_signal , con , cv , mode , timeout , n , environment(),
168168 function () {
169- cb <- data $ callback
170- if (! is.null (cb )) {
169+ cb <- .subset2( data , " callback" )
170+ if (is.function (cb )) {
171171 cb(data )
172172 }
173173 }
@@ -180,14 +180,15 @@ is.promising.recvAio <- function(x) {
180180
181181# ' @exportS3Method promises::as.promise
182182as.promise.recvAio <- function (x ) {
183- prom <- x $ promise
184183
185- if (is.null(prom )) {
186- prom <- promises :: promise(function (resolve , reject ) {
184+ promise <- .subset2(x , " promise" )
185+
186+ if (is.null(promise )) {
187+ promise <- promises :: promise(function (resolve , reject ) {
187188 assign(" callback" , function (... ) {
188189
189190 # WARNING: x$data is heavily side-effecty!
190- value <- x $ data
191+ value <- .subset2( x , " data" )
191192
192193 if (is_error_value(value )) {
193194 reject(simpleError(nng_error(value )))
@@ -202,19 +203,20 @@ as.promise.recvAio <- function(x) {
202203
203204 if (! inherits(value , " unresolvedValue" )) {
204205 if (is_error_value(value )) {
205- prom <- promises :: promise_reject(simpleError(nng_error(value )))
206+ promise <- promises :: promise_reject(simpleError(nng_error(value )))
206207 } else {
207- prom <- promises :: promise_resolve(value )
208+ promise <- promises :: promise_resolve(value )
208209 }
209210 }
210211
211212 # Save for next time. This is not just an optimization but essential for
212213 # correct behavior if as.promise is called multiple times, because only one
213214 # `callback` can exist on the recvAio object at a time.
214- assign(" promise" , prom , x )
215+ assign(" promise" , promise , x )
215216 }
216217
217- prom
218+ promise
219+
218220}
219221
220222# Core aio functions -----------------------------------------------------------
0 commit comments