Skip to content

Commit

Permalink
update docs, required that uses single function for uv_spawn setup
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechsTech committed Mar 27, 2020
1 parent f6931a6 commit 395c705
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 28 deletions.
4 changes: 1 addition & 3 deletions Coroutine/Coroutine.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,7 @@ public function __construct(?string $driver = 'auto')
if (\in_array($driver, ['auto', 'uv']) && \function_exists('uv_loop_new')) {
$this->uv = \uv_loop_new();

Spawn::bypass();
Spawn::uvLoop($this->uv);
Spawn::yield();
Spawn::setup($this->uv);

// @codeCoverageIgnoreStart
$this->onEvent = function ($event, $status, $events, $stream) {
Expand Down
46 changes: 22 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,15 @@ yield \cancel_task($tid);
*/
yield \spawn_task($command, $timeout);

/**
* Add and wait for result of an blocking `I/O` subprocess that runs in parallel.
* - This function needs to be prefixed with `yield`
*
* @see https://docs.python.org/3.7/library/asyncio-subprocess.html#subprocesses
* @see https://docs.python.org/3.7/library/asyncio-dev.html#running-blocking-code
*/
yield \spawn_await($callable, $timeout, $display, $channel, $channelTask, $signal, $signalTask);

/**
* Wait for the callable/task to complete with a timeout.
* Will continue other tasks until so.
Expand Down Expand Up @@ -327,13 +336,24 @@ yield \input_wait($size);

```php
/**
* Add and wait for result of a blocking `subprocess` that runs in parallel.
* Add and wait for result of an blocking `I/O` subprocess that runs in parallel.
* This function turns the calling function internal __state/type__ used by `gather()`
* to **process/paralleled** which is handled differently.
* - This function needs to be prefixed with `yield`
*
* @see https://docs.python.org/3.7/library/asyncio-subprocess.html#subprocesses
* @see https://docs.python.org/3.7/library/asyncio-dev.html#running-blocking-code
*/
yield \await_process($command, $timeout);
yield \add_process($command, $timeout);
```

```php
/**
* Executes a blocking system call asynchronously either natively thru `libuv`, `threaded`, or it's `uv_spawn`
* feature, or in a **child/subprocess** by `proc_open`, if `libuv` is not installed.
* - This function needs to be prefixed with `yield`
*/
yield \file_***Any File System Command***( ...$arguments);
```

```php
Expand All @@ -353,28 +373,6 @@ yield \await_process($command, $timeout);
\coroutine_run($coroutine);
```

```php
/**
* Add something/callable to `coroutine` process pool
*/
\parallel($callable, $timeout);

/**
* Get/create process worker pool of an parallel instance.
*/
\parallel_pool();

/**
* Add something/callable to parallel instance process pool.
*/
\parallel_add($somethingToRun, $timeout);

/**
* Execute process pool, wait for results. Will do other stuff come back later.
*/
\parallel_wait();
```

## Installation

```cmd
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
],
"require": {
"php": ">7.2",
"symplely/spawn": "^1.0.5"
"symplely/spawn": "^1.0.6"
},
"autoload": {
"files": [
Expand Down

0 comments on commit 395c705

Please sign in to comment.