What's the difference between Swift's Dispatchqueue and Flutter's Future?

103

DispatchQueue is for parallelization your tasks. It works according to the first in first out principle, means the first tasks will be done first etc. A Future sounds for me like a "delayed" task, means your task will be done in the future but not in the background like in a DispatchQueue. Some good information for DispatchQueue are here Appropriately-using-dispatchqueue-main :-)

Share:
103
Moh. Absar Rahman
Author by

Moh. Absar Rahman

Updated on January 01, 2023

Comments

  • Moh. Absar Rahman
    Moh. Absar Rahman over 1 year

    First of all please don't laugh at my question I am still a newbie. Recently I have started learning iOS development and found about Dispatchqueue (documentation link). After reading the documentation, I had a question on my mind.

    • Is it similar like Flutter's Future(documentation link)? Or are there any differences between them? If yes, then what are the differences?

    I searched a lot but couldn't find a proper answer which would clear my confusion. Thanks in advance.

    • Fogmeister
      Fogmeister over 2 years
      Someone will be able to provide a more complete answer but at a high level... DispatchQueue is more like a thread so different queues can be used to do work concurrently. Whereas Future is a promise that it will contain some value at some point in the ... erm ... future. Like if you are downloading an image you could use Future<Image>. Incidentally, Swift.Combine also has a Future, it is a fairly common idea across different programming languages..