--- title: Introduction permalink: / --- `amphp/parallel-functions` is a simplifying layer on top of [`amphp/parallel`](https://github.com/amphp/parallel). It allows parallel code execution by leveraging threads or processes, depending on the installed extensions. All data sent to / received from the child processes / threads must be serializable using PHP's `serialize()` function. {:.warning} > This library uses [`opis/closure`](https://github.com/opis/closure) to serialize closures, so its restrictions apply. > If serialization of a particular closure doesn't work, you can always write an autoloadable function and call that by name instead. {:.note} > PHP's resources aren't serializable and will silently be casted to integers on serialization. ## Installation This package can be installed as a [Composer](https://getcomposer.org/) dependency. ```bash composer require amphp/parallel-functions ``` ## Configuration The functions in this library do not require an instance of `Amp\Parallel\Worker\Pool` to be provided. When a pool instance is not provided, the default worker pool in `amphp/parallel` is used, which can be configured using `Amp\Parallel\Worker\pool()` in version 0.2 of `amphp/parallel`. The default maximum number of workers is 32. ## Usage Like all other `amphp` libraries, this library works in a fully asynchronous world. It returns promises as placeholders for future results of operations. You don't need to know any details to use this library in traditional, fully synchronous applications. All you need is wrapping every function returning an [`Amp\Promise`](https://amphp.org/amp/promises/) with [`Amp\Promise\wait()`](https://amphp.org/amp/promises/miscellaneous#wait). {:.warning} > Don't write anything directly (using `fwrite()` / `fputs()`) to `STDOUT` inside functions executed in parallel. > This will break the communication channel with the parent. > You can use `echo` / `print` / `var_dump` just as normal, these will automatically be redirected to `STDERR` of the parent. ```php