Download the PHP package vatson/isolated-callback without Composer
On this page you can find all versions of the php package vatson/isolated-callback. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package isolated-callback
Isolated Callback
Tiny but still powerful tool to fork it all.
Isolated callback allows to execute any callable statement in a fork and avoid memory leaks.
Installation
Installation is damn easy, thanks to Composer:
composer require vatson/isolated-callback
or add the requirements to your composer.json file
{
"require": {
"vatson/isolated-callback": "*"
}
}
and run update
composer update vatson/isolated-callback
Usage
Quick and easy. Let's create some anonymous function that generates a lot of data, but the result is a small
That's it. Your callback will be run in separate fork and the result will be sent to the main process.
Callback arguments
Note, you can call it with args and bind some local vars with your lambda functions.
Objects as a result
Also you can send not only scalars, but simple objects (POPO). And rember, objects based on or which contain Resources
can't be serialized as a result.
Restrictions
Beware, the current implementation uses System V IPC to share a result between processes. Amount of transferred data depends on your system configuration. The best practice is to send short but succinct results.
Requirements
-
PHP >= 5.3.2
-
Process Control (PCNTL) - allows to make a fork
-
System V IPC (semaphore) - adds an ability to share the results between distributed processes
-
[Optional] Fumocker - mocks the php's built-in functions
- [Optional] PHPUnit 3.5+ to execute the test suite
Authors
-
twitter)
- Slava Hatnuke
License
Isolated Callback is distributed under the terms of the MIT license - see the LICENSE
file for details
All versions of isolated-callback with dependencies
ext-pcntl Version *
ext-sysvsem Version *