format: Query / display coroutine properties and state.

format.coroutineR Documentation

Query / display coroutine properties and state.

Description

The coroutine format method displays its source code, its effective environment, whether it is running or finished, and a label indicating its last known state. The summary method returns the same information in a list.

summary(obj) returns a list with information on a coroutine's state, including:

  • code: the expression used to create the coroutine;

  • state: the current state (see below);

  • node: is a character string that identifies a location in the coroutine source code; for example, a typical state string might be ".{.<-2.await__then", which can be read like "in the first argument of ⁠\{⁠, in the second argument of ⁠<-⁠, in a call to await(), at internal node then.";

  • envir: the environment where the coroutine is evaluating R expressions;

  • err: the error object, if the coroutine caught an error.

summary(g)$state for a generator g might be "yielded", "running" (if nextElem is currently being called,) "stopped" (for generators that have stopped with an error,) or "finished" (for generators that have finished normally.)

summary(a)$state of an async might be "pending", "resolved" or "rejected".

summary(s)$state on a stream might be "resolved", "rejected", "running", "woken", "yielding", or "yielded".

Usage

## S3 method for class 'coroutine'
format(x, ...)

## S3 method for class 'coroutine'
summary(object, ...)

## S3 method for class 'generator'
summary(object, ...)

## S3 method for class 'async'
summary(object, ...)

## S3 method for class 'stream'
summary(object, ...)

Arguments

x

A coroutine.

...

Undocumented.

object

a coroutine (async, generator, or stream) object.


crowding/generators documentation built on June 28, 2023, 6:14 a.m.