# How do you use AsyncStream to make Task execution deterministic?

**URL:** <https://forums.swift.org/t/how-do-you-use-asyncstream-to-make-task-execution-deterministic/57968>\
**Category:** Using Swift\
**Tags:** concurrency\
**Created:** [June 10, 2022, 2:36am UTC](https://forums.swift.org/t/how-do-you-use-asyncstream-to-make-task-execution-deterministic/57968 "2022-06-10T02:36:29Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![gabeshahbazian](https://avatars.discourse-cdn.com/v4/letter/g/34f0e0/32.png) [@gabeshahbazian](https://forums.swift.org/u/gabeshahbazian)\
**Post date:** [June 11, 2022, 8:00pm UTC](https://forums.swift.org/t/how-do-you-use-asyncstream-to-make-task-execution-deterministic/57968/18 "2022-06-11T20:00:57Z")

</div>

I've written a version of a queue which can run async closures with `n` amount of parallelization here: [playgrounds/TaskQueue.swift at main · gshahbazian/playgrounds · GitHub](https://github.com/gshahbazian/playgrounds/blob/main/AsyncAwait.playground/Sources/TaskQueue.swift)

Initializing with `TaskQueue(concurrency: 1)` provides FIFO execution.

Would love to get some feedback on this implementation : )

---

_[View the full topic](https://forums.swift.org/t/how-do-you-use-asyncstream-to-make-task-execution-deterministic/57968)._
