c# - Simple way to yield an array in parallel -
newer version of c# has async
/await
. in unity there yield
. how implement method can yield
in parallel?
similar promise.all([])
in javascript, don't care 1 finishes first, care when done.
to give more context, imagine designing procedural terrain generator generate in chunks; , have setup each chunk generate using threadpool
, , provide api returns ienumerator
:
ienumerator generatechunk() { // procedural generation // queue onto threadpool // when done, yield } ienumerator generatechunks() { (int = 0; < chunks.length; i++) { yield return chunks[i].generatechunk(); } } void generatemap() { startcoroutine(generatechunks()); }
can yield ienumerator[]
?
update: not sure have expressed myself clearly. want kick start generatechunk
@ once, , allow them finish fast possible, instead of yielding 1 after another.
is code doing that, or need else?
yield return startcoroutine(chunks[i].generatechunk());
Comments
Post a Comment