Debian Codegraph @

man/call_aio.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/aio.R
3 \name{call_aio}
4 \alias{call_aio}
5 \alias{call_aio_}
6 \title{Call the Value of an Asynchronous Aio Operation}
7 \usage{
8 call_aio(x)
9
10 call_aio_(x)
11 }
12 \arguments{
13 \item{x}{an Aio or list of Aios (objects of class 'sendAio', 'recvAio' or
14 'ncurlAio').}
15 }
16 \value{
17 The passed object (invisibly).
18 }
19 \description{
20 \code{call_aio} retrieves the value of an asynchronous Aio operation, waiting
21 for the operation to complete if still in progress. For a list of Aios, waits
22 for all asynchronous operations to complete before returning.
23
24 \code{call_aio_} is a variant that allows user interrupts, suitable for
25 interactive use.
26 }
27 \details{
28 For a 'recvAio', the received value may be retrieved at \verb{$data}.
29
30 For a 'sendAio', the send result may be retrieved at \verb{$result}.
31 This will be zero on success, or else an integer error code.
32
33 To access the values directly, use for example on a 'recvAio' \code{x}:
34 \code{call_aio(x)$data}.
35
36 For a 'recvAio', if an error occurred in unserialization or conversion of the
37 message data to the specified mode, a raw vector will be returned instead to
38 allow recovery (accompanied by a warning).
39
40 Note: this function operates silently and does not error even if \code{x} is not
41 an active Aio or list of Aios, always returning invisibly the passed object.
42 }
43 \section{Alternatively}{
44
45
46 Aio values may be accessed directly at \verb{$result} for a 'sendAio', and \verb{$data}
47 for a 'recvAio'. If the Aio operation is yet to complete, an 'unresolved'
48 logical NA will be returned. Once complete, the resolved value will be
49 returned instead.
50
51 \code{\link[=unresolved]{unresolved()}} may also be used, which returns \code{TRUE} only if an Aio or Aio
52 value has yet to resolve and \code{FALSE} otherwise. This is suitable for use in
53 control flow statements such as \code{while} or \code{if}.
54 }
55
56 \examples{
57 s1 <- socket("pair", listen = "inproc://nanonext")
58 s2 <- socket("pair", dial = "inproc://nanonext")
59
60 res <- send_aio(s1, data.frame(a = 1, b = 2), timeout = 100)
61 res
62 call_aio(res)
63 res$result
64
65 msg <- recv_aio(s2, timeout = 100)
66 msg
67 call_aio_(msg)$data
68
69 close(s1)
70 close(s2)
71
72 }