Description Usage Arguments Details Value Note Author(s) See Also Examples
Q.collect
returns the queue's first available result in a standardized format.
Q.pop
is a simplified version of Q.collect that returns the pure result without any further information.
Q.collect.all
and Q.pop.all
return all results that are currently available in the queue.
Q.isready
returns TRUE
if there is a result available in the queue, FALSE
otherwise.
1 2 3 4 5 6 7 |
Q |
A job queue as created by |
tag |
Setting |
wait |
Maximum total time to wait until a result becomes available (in seconds). Logical values |
write |
Set |
timeout |
Time to wait (in seconds) for the socket to respond. |
Q.collect
returns a list containing the result at entry $value
. The return value always contains a boolean entry $has.result
which is FALSE
if there was no result to be read (either because queue has not been tasked with anything or no result is ready for pick-up yet), TRUE
otherwise. If a result could be read from the socket, then the return value contains the entry $success
which is FALSE
if the computation produced an error. Furthermore, if the job was sent with values for tag and tranche, then the result contains these values at entries $tag
and $tranche
.
Q.collect
discards muted results and returns the first available non-muted result. Setting tag
will cause Q.collect
to return the first available result with the corresponding tag. If no result with this tag becomes available within the waiting time, then the result's has.result
field is FALSE
. If you set a tag, make sure wait is not set to 0/FALSE
to give the queue time to sieve through the available results.
Q.pop
is a simple version of Q.collect
that only returns the result (without has.result
, tag
, tranche
, etc.). Note: a NULL
return value may either mean that the return value was NULL
or that there was no result available at this time. Use Q.collect
if you need to tell the difference.
Q.collect.all
and Q.pop.all
return all results that are currently available in the queue. There is no wait
parameter as this would be practically equivalent to a construction like Sys.sleep(wait); Q.collect.all(Q)
.
There is usually no need to use Q.isready
since Q.collect
's has.result
field indicates whether the queue was ready.
Q.collect
returns a list which is guaranteed to have a logical field has.result
. If has.result=TRUE
, then the result also has a logical field success
indicating whether or not an error occurred, and a field value
containing the actual job result.
Q.pop
simply returns the value
field of Q.collect
.
Q.collect.all
and Q.pop.all
return lists of elements in the respective formats.
Q.isready
returns logical.
If tag is specified for any of the retrieval functions, then available results with different tags will still be retrieved from the socket but stored in Q$data$rack
for later retrieval from the queue. This is handled automatically by the queue.
Bastian Laubner
Q.make
, as well as Q.push
and jobqueue
for further examples.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | Q = Q.make()
Q.push(Q, "Some job")
# safe way to check if the job returned a value
job = Q.collect(Q)
if (job$has.result) {
# do something with the result
print(job$value)
}
# safe way with error checking
if (job$has.result) {
if (job$success) {
# do something with the job result
print(job$value)
} else {
# an error occurred during processing, error message in job$value
stop(job$value)
}
}
Q.close(Q)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.