1212# ' @return The passed Aio object (invisibly), or NULL if non-blocking and the
1313# ' Aio has yet to resolve.
1414# '
15- # ' @details To access the values directly, use for example on a sendAio 'x':
16- # ' \code{call_aio(x)$result}.
15+ # ' @details For a 'recvAio', the received raw vector will be attached in \code{$raw}
16+ # ' (unless 'keep.raw' was set to FALSE when receiving), and the converted R
17+ # ' object in \code{$data}.
1718# '
1819# ' For a 'sendAio', the send result will be attached to the Aio in \code{$result}.
1920# ' This will be zero on success.
2021# '
21- # ' For a 'recvAio', the received raw vector will be attached in \code{$raw}
22- # ' (unless 'keep.raw' was set to FALSE when receiving), and the converted R
23- # ' object in \code{$data}.
22+ # ' To access the values directly, use for example on a sendAio 'x':
23+ # ' \code{call_aio(x)$result}.
2424# '
2525# ' For a 'recvAio', in case of an error in unserialisation or data conversion,
2626# ' the received raw vector will always be saved in \code{$raw} to allow the
2727# ' data to be recovered.
2828# '
29- # ' Once the result is retrieved, the Aio is deallocated and only the result
30- # ' is stored in the Aio object.
29+ # ' Once the result has been successfully retrieved, the Aio is deallocated
30+ # ' and only the result is stored in the Aio object.
3131# '
3232# ' @section Non-blocking:
3333# '
@@ -68,11 +68,11 @@ call_aio <- function(aio, block = TRUE) {
6868
6969 if (inherits(aio , " recvAio" )) {
7070
71- if (! missing(block ) && ! isTRUE(block )) {
71+ if (missing(block ) || isTRUE(block )) {
72+ res <- .Call(rnng_aio_wait_get_msg , .subset2(aio , " aio" ))
73+ } else {
7274 res <- .Call(rnng_aio_get_msg , .subset2(aio , " aio" ))
7375 missing(res ) && return ()
74- } else {
75- res <- .Call(rnng_aio_wait_get_msg , .subset2(aio , " aio" ))
7676 }
7777 mode <- .subset2(aio , " callparams" )[[1L ]]
7878 keep.raw <- .subset2(aio , " callparams" )[[2L ]]
@@ -99,11 +99,11 @@ call_aio <- function(aio, block = TRUE) {
9999
100100 } else if (inherits(aio , " sendAio" )) {
101101
102- if (! missing(block ) && ! isTRUE(block )) {
102+ if (missing(block ) || isTRUE(block )) {
103+ res <- .Call(rnng_aio_wait_result , .subset2(aio , " aio" ))
104+ } else {
103105 res <- .Call(rnng_aio_result , .subset2(aio , " aio" ))
104106 missing(res ) && return ()
105- } else {
106- res <- .Call(rnng_aio_wait_result , .subset2(aio , " aio" ))
107107 }
108108 aio [[" result" ]] <- res
109109 rm(" aio" , envir = aio )
0 commit comments