From a5b5a58d06fd3fa61fa43117d56f1c1de35b46e7 Mon Sep 17 00:00:00 2001 From: Joop Schilder Date: Tue, 22 Jan 2019 14:08:45 +0100 Subject: [PATCH] Update in README. Trimmed down the shared memory block size. --- README.md | 8 +++++--- src/Asynchronous.php | 4 ++-- src/Runtime.php | 20 +------------------- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index ca8958f..c91c099 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ # joopschilder/php-async Asynchronous PHP callable processing with return values via SysV shared memory.
Requires the `php-sysvshm` extension.
-Works with PHP >= 5.3 due to `shm_attach(...)` returning a resource instead of an int.
+Works with PHP >= 5.3 due to `shm_attach(...)` returning a resource instead of an int.

+Note: This package should not be used in a CGI environment, as each PHP runtime that makes a call on the async functions WILL +create an 8MB shared memory block in RAM. If you run out of memory: you have been warned.
-Note: This project is merely an experiment. It is, however, available on packagist. -If you think your project lacks witchcraft combined with black magic, just add this package to your `composer.json`: +Note: This project is an experiment. It is, however, available on packagist. +If you think your project lacks witchcraft and black magic, just add this package to your `composer.json`: ```json { "require": { diff --git a/src/Asynchronous.php b/src/Asynchronous.php index 8f1c4f9..ffcad0b 100644 --- a/src/Asynchronous.php +++ b/src/Asynchronous.php @@ -8,7 +8,7 @@ namespace JoopSchilder\Asynchronous; */ class Asynchronous { - public const BLOCK_SIZE_MB = 32; + public const BLOCK_SIZE_MB = 8; private const BLOCK_SIZE_BYTES = self::BLOCK_SIZE_MB * (1024 ** 2); /** @var Asynchronous|null */ @@ -75,7 +75,7 @@ class Asynchronous * On failure, write a default response to the block in order for * the Promise to be able to resolve. */ - Runtime::setChild(); + Runtime::markChild(); $instance->_attachToShm(); try { diff --git a/src/Runtime.php b/src/Runtime.php index 130a81d..f1ad26e 100644 --- a/src/Runtime.php +++ b/src/Runtime.php @@ -20,30 +20,12 @@ class Runtime /** * */ - public static function setChild() + public static function markChild() { self::$inParentRuntime = false; } - /** - * - */ - public static function setParent() - { - self::$inParentRuntime = true; - } - - - /** - * @return bool - */ - public static function isParent() - { - return self::$inParentRuntime; - } - - /** * @return bool */