asyncBuffer docs are misleading
See original GitHub issueI made a mistake when I got rid of asyncMapParallel
and other parallel functions. I thought I could instead have parallelism be created with asyncBuffer
. asyncBuffer
is still useful and has a correct implementation and example, however the docs suggest (as I was thinking) that the method can create parallelism, which it cannot. Making multiple requests to an async generator simply queues them.
Here is an example of code that I just wrote in macrome where I want parallelism and I believe I have implemented it correctly:
const initialPaths = await traverse(this.projectRoot, { ignored });
const operations = await execPipe(
initialPaths,
filter((path) => !!this.generatorInstances.find(({ generator }) => matches(path, generator))),
map((path) =>
this.parserFor(path)
.hasHeader(path)
.then((h) => (h ? { path, operation: ADD } : null)),
),
asyncBuffer(4),
asyncFilter((op) => op !== null),
arrayFromAsync,
);
this.initialProcess(operations);
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:26 (15 by maintainers)
Top Results From Across the Web
Why Does Reading Data from the dsp.AsyncBuffer Object ...
AsyncBuffer object writes the data input u to the buffer. When input on the cmd port is 0, the object reads data from...
Read more >Swift Async Algorithms: Buffer
Buffering is a common mechanism to smooth out demand to account for production that may be able to emit more quickly at some...
Read more >DeflateStream.ReadAsync disregards Memory<byte> ...
When I read from the stream using the asynchronous var bytesRead = DeflateStream.ReadAsync(memoryBuffer); the buffer is only partially ...
Read more >javascript - async/await functions have strange behaviour
1 Answer 1 ... The problem lies within: dataBuffer.forEach(async (data, index) => { // ... }); Although the callback function is an async...
Read more >AsyncStream | Apple Developer Documentation
Constructs an asynchronous stream for an element type, using the specified buffering policy and element-producing closure. ... A strategy that handles exhaustion ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve used twice, in completely different projects.
The first one was an alerting engine.
The second use case (which I’m working on now) is polling a legacy SQL database for new records in a particular table and then acting on them in an asynchronous manner.
Invariant 3 is already pretty much a guarantee in the iterator spec. Any iterators implemented with generator functions will force effectively serial calls to
next()
. Generators do this by buffering the calls tonext()
. That is one thing that makes it difficult to come up with inventive solutions. I really do not want to break with generator semantics.