Update in README.

Trimmed down the shared memory block size.
This commit is contained in:
Joop Schilder 2019-01-22 14:08:45 +01:00
parent be444f3b45
commit a5b5a58d06
3 changed files with 8 additions and 24 deletions

View File

@ -1,10 +1,12 @@
# joopschilder/php-async # joopschilder/php-async
Asynchronous PHP callable processing with return values via SysV shared memory.<br/> Asynchronous PHP callable processing with return values via SysV shared memory.<br/>
Requires the `php-sysvshm` extension.<br/> Requires the `php-sysvshm` extension.<br/>
Works with PHP >= 5.3 due to `shm_attach(...)` returning a resource instead of an int.<br/> Works with PHP >= 5.3 due to `shm_attach(...)` returning a resource instead of an int.<br/><br/>
<b>Note:</b> 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.
<br/> <br/>
<b>Note:</b> This project is merely an experiment. It is, however, available on packagist. <b>Note:</b> This project is 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`: If you think your project lacks witchcraft and black magic, just add this package to your `composer.json`:
```json ```json
{ {
"require": { "require": {

View File

@ -8,7 +8,7 @@ namespace JoopSchilder\Asynchronous;
*/ */
class 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); private const BLOCK_SIZE_BYTES = self::BLOCK_SIZE_MB * (1024 ** 2);
/** @var Asynchronous|null */ /** @var Asynchronous|null */
@ -75,7 +75,7 @@ class Asynchronous
* On failure, write a default response to the block in order for * On failure, write a default response to the block in order for
* the Promise to be able to resolve. * the Promise to be able to resolve.
*/ */
Runtime::setChild(); Runtime::markChild();
$instance->_attachToShm(); $instance->_attachToShm();
try { try {

View File

@ -20,30 +20,12 @@ class Runtime
/** /**
* *
*/ */
public static function setChild() public static function markChild()
{ {
self::$inParentRuntime = false; self::$inParentRuntime = false;
} }
/**
*
*/
public static function setParent()
{
self::$inParentRuntime = true;
}
/**
* @return bool
*/
public static function isParent()
{
return self::$inParentRuntime;
}
/** /**
* @return bool * @return bool
*/ */