> For the complete documentation index, see [llms.txt](https://venndev.gitbook.io/vapm/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://venndev.gitbook.io/vapm/coroutinegen.md).

# CoroutineGen

Slightly different from the asynchronous ideas on this feature is based on the [**`Generator`**](https://www.php.net/manual/en/language.generators.php) as a whole.

Let's take a look at its interface.

<pre class="language-php"><code class="lang-php"><strong> /**
</strong>  * @return SplQueue|null
  *
  * This function returns the task queue.
  */
 public static function getTaskQueue(): ?SplQueue;

 /**
  * @param mixed ...$coroutines
  * @return void
  *
  * This is a blocking function that runs all the coroutines passed to it.
  */
 public static function runNonBlocking(mixed ...$coroutines): void;

 /**
  * @param mixed ...$coroutines
  * @return void
  *
  * This is a blocking function that runs all the coroutines passed to it.
  */
 public static function runBlocking(mixed ...$coroutines): void;

 /**
  * @param callable $callback
  * @param int $times
  * @return Closure
  *
  * This is a generator that runs a callback function a specified amount of times.
  */
 public static function repeat(callable $callback, int $times): Closure;

 /**
  * @param int $milliseconds
  * @return Generator
  *
  * This is a generator that yields for a specified amount of milliseconds.
  */
 public static function delay(int $milliseconds): Generator;

 /**
  * @return void
  *
  * This function runs the task queue.
  */
 public static function run(): void;
</code></pre>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://venndev.gitbook.io/vapm/coroutinegen.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
