Skip to content

Amp\disperse() function#460

Open
rela589n wants to merge 1 commit intoamphp:3.xfrom
rela589n:feature-disperse-function
Open

Amp\disperse() function#460
rela589n wants to merge 1 commit intoamphp:3.xfrom
rela589n:feature-disperse-function

Conversation

@rela589n
Copy link
Copy Markdown

In this pull request, I want to introduce a disperse($closures) function.

It is created to asynchronously execute an array of closures when the client needs all results.

$results = \Amp\disperse([
    fn () => $httpClient->request(new Request('https://www.google.com', 'HEAD')),
    fn () => $httpClient->request(new Request('https://www.bing.com', 'HEAD')),
]);

Initially, I considered placing this function in Amp\Future namespace, but later I opted in favor of Amp, since this function doesn't have Futures in the signature.

Comment thread src/functions.php Outdated
@xpader
Copy link
Copy Markdown
Contributor

xpader commented Mar 27, 2026

What is that??? await(iterable $futures) race order version ???
I don't think we need add this to amp library.

@rela589n rela589n force-pushed the feature-disperse-function branch from 4270738 to 3a32eb7 Compare March 27, 2026 06:54
@rela589n rela589n force-pushed the feature-disperse-function branch from 3a32eb7 to 85eb948 Compare March 27, 2026 06:55
@rela589n
Copy link
Copy Markdown
Author

@xpader , if you don't find this useful at all, you are the contributor, and I'm a layman - it's in your authority to close.

@rela589n
Copy link
Copy Markdown
Author

rela589n commented Apr 6, 2026

Maybe this's not the best name for such a function.
Maybe naming it some other way would bring clarity?
What's on your mind?

@rela589n rela589n requested review from kelunik and xpader April 9, 2026 16:29
webpatser added a commit to webpatser/fledge-fiber that referenced this pull request Apr 10, 2026
Security:
- Fix HTTP/2 ping flood on active streams (amphp/http-server#386)

Bug fixes:
- Use VarString for string params in binary protocol (amphp/mysql#142)
- Decode BIT columns as int instead of string (amphp/mysql#138)
- Close connections on pool destruct (amphp/http-client#396)
- Fix duplicate keys in byte-stream split() (amphp/byte-stream#113)
- Fix Closure type annotation for static analysis (amphp/amp#451)
- Safely handle DisposedException on unsubscribe (amphp/redis#100)

Features:
- Add TLS support for Redis connections (amphp/redis#98)
- Add disperse() for concurrent closure execution (amphp/amp#460)
@rela589n
Copy link
Copy Markdown
Author

Hi, @webpatser, do you think it's a good thing to include?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants