What is Operation queue | Operation queue vs dispatch (GCD) in swift | Hindi tutorial

Поділитися
Вставка
  • Опубліковано 2 сер 2024
  • Operation queue class and dispatch framework GCD are two important names that come to every iOS developer's mind when they are dealing with multi-threading. Mostly we use GCD (Grand Central Dispatch) for the majority of our operations but then if everything can be done by GCD then what's the use of operation queue class? why did apple invest their time in making this class?
    In this Swift video tutorial, we shall explore what is operation and operation queue and along with that we will explore the features that separate operation queue from the dispatch framework
    Given are the chapters in this video
    0:00 Introduction
    0:16 background
    1:39 request
    2:13 what is operation?
    5:04 what is operationqueue?
    7:47 start method or operationqueue?
    8:39 Operation queue vs GCD
    10:38 multiple block execution
    12:37 opinion
    13:21 conclusion
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ✅ Subscribe to the channel and stay ahead of everyone by following the right way for writing clean code in swift. 🔥🔥🔥🔥🔥
    🔗Click on the link to subscribe: ua-cam.com/users/codecat?sub...
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Introduction to threading video: • Threads in iOS Swift T...
    -----------------------------------------------------------------------------------------------------------------------
    📥 Download the source code from
    GitHub: github.com/codecat15/UA-cam-...
    Google Drive: drive.google.com/file/d/1spEl...
    -----------------------------------------------------------------------------------------------------------------------
    ############################################
    Connect with me on social media
    📷 : / codecat15
    📧: codecat15@gmail.com
    🐦: / codecat15
    Facebook: / code.cat.792
    Github: github.com/codecat15
    ###########################################
    #operationQueue #gcd #operationQueuevsGCD

КОМЕНТАРІ • 112

  • @MandeepSingh-ly3jj
    @MandeepSingh-ly3jj 3 роки тому +6

    Huge Respect for Ravi Sir, He is genius Guy, With the help of him videos related to an iOS , I was selected in reputed company , and now I have around 2year of experience and salary package is also great . all credit to Ravi sir. Salute to this man bcz I was selected in covid time and also I supported to my family with my earning. Again Really thanks from my heart. :)))

  • @vyankateshshivnikar7932
    @vyankateshshivnikar7932 Рік тому +2

    Excellent Video Guruji🙇‍♂

    • @CodeCat15
      @CodeCat15  Рік тому +1

      Thank you Vyankatesh 🙏

  • @bhanusreebukya2621
    @bhanusreebukya2621 3 роки тому +1

    Just Awesome. Your videos are making ur learning easier and clearer. Grateful and Appreciate your hardwork.

  • @naveenchatla3877
    @naveenchatla3877 Рік тому +1

    I am really confused before this video about queues.. now am good about gcd & Operation queues

    • @CodeCat15
      @CodeCat15  Рік тому

      glad this helped, please feel free to ask questions and do share the channel with your ios group.

  • @muhammadhussainmughal4553
    @muhammadhussainmughal4553 7 місяців тому

    I hear about operation queue for the first time from your video....thank you so much sir❤

  • @apekshachaubey944
    @apekshachaubey944 3 роки тому +2

    @Code Cat - Ravi quotes at starting of every video is good n motivating and off course ... all videos are clear n easy to understand. Good Work !!

    • @CodeCat15
      @CodeCat15  3 роки тому +1

      Thank you so much 😀 Apeksha, I am glad these videos are being helpful. Please do feel free to ask questions and do share the channel with anyone who wants to learn swift or with your iOS group.

  • @iamwaseem99
    @iamwaseem99 3 роки тому +4

    Great tutorial as always. Perfect and clear on point. 👌

    • @CodeCat15
      @CodeCat15  3 роки тому +1

      Thanks Waseem, am glad this was helpful

  • @VirendraKumar-zf1yg
    @VirendraKumar-zf1yg 3 роки тому +1

    I really want to say thanks for excellent explanation.

  • @tejas786u
    @tejas786u 2 роки тому

    Thanks for this great explanation. I have heard about the concept but never used before because of my concept was not clear about this. But this is really amazing explanation. Keep posting such great work.

  • @r_p_a_r_k541
    @r_p_a_r_k541 2 роки тому +1

    I am hearing about operation queue for first time... Great video 👍 thanks for the video

    • @CodeCat15
      @CodeCat15  2 роки тому

      Am glad you liked it, do share the video with your iOS group and always feel free to ask questions

  • @AnkitSoni30
    @AnkitSoni30 3 роки тому +2

    congratulations on 3k.. keep going..

    • @CodeCat15
      @CodeCat15  3 роки тому +1

      Thank you Ankit 😊

  • @poojanegi9786
    @poojanegi9786 5 місяців тому +1

    You were right.. we compare maine jo pdha h usme to aisa hota hai i thought i am the only one with this problem seems lots of people face this issues... but you explained very well... how threading work and all.

    • @CodeCat15
      @CodeCat15  2 місяці тому

      Thank you pooja, i am glad the video was helpful

  • @adityarajgupta6061
    @adityarajgupta6061 3 роки тому +2

    Such a very helpful video and my confusion got cleared after watching this. You just opened my mind..Thanks buddy.

    • @CodeCat15
      @CodeCat15  3 роки тому +1

      Thanks Aditya, am glad this video was helpful 👍

  • @U-and-Mee
    @U-and-Mee 25 днів тому

    Superb series.

  • @keertikagupta
    @keertikagupta 2 роки тому

    Again brilliant content.

  • @khaleelsheik8136
    @khaleelsheik8136 3 роки тому

    Excellent , i Loved it Ravi

  • @icodingschool9018
    @icodingschool9018 3 роки тому +1

    super se Abhi upar ....perfect explanation

  • @polu9132
    @polu9132 3 роки тому +1

    classy as always. lots of love

    • @CodeCat15
      @CodeCat15  3 роки тому

      Thank you Polu :) do share this video with your iOS group too

  • @BABEENGINEER
    @BABEENGINEER 2 роки тому +1

    even though I don't understand Hindi, the english subtitles helped and this was a very thorough video and easy to understand

    • @CodeCat15
      @CodeCat15  2 роки тому +1

      I am glad the content was helpful, writing subtitles takes a ton of manual work but I try.

  • @akashrevanna5327
    @akashrevanna5327 3 роки тому

    Nice explaination 🙏

  • @aafaqahmed2265
    @aafaqahmed2265 2 роки тому

    Awesome

  • @palakgandhi1900
    @palakgandhi1900 3 роки тому +2

    GCD on steroids 🤣. Nice work code cat. Your videos are easy to grasp and retain for long since you give such good examples.

    • @CodeCat15
      @CodeCat15  3 роки тому +1

      Welcome to the channel Palak, and am glad these videos are helpful

    • @palakgandhi1900
      @palakgandhi1900 3 роки тому

      @@CodeCat15 :)

  • @rakeshmahato5326
    @rakeshmahato5326 2 роки тому +1

    Thanks Ravi, very well explained when to use GCD and OperationQueue

    • @CodeCat15
      @CodeCat15  2 роки тому

      Glad you liked it and thank you for your kind words Rakesh

  • @rohandhankani3962
    @rohandhankani3962 3 роки тому +1

    Grear explanation. Amazing, thank you very much

  • @amitprajapati3621
    @amitprajapati3621 3 роки тому +1

    Mind boggling explanation🤘

    • @CodeCat15
      @CodeCat15  3 роки тому

      Thank you so much 😀

  • @khushaljhalani
    @khushaljhalani 3 роки тому +1

    awesome explanation. thanks Ravi

    • @CodeCat15
      @CodeCat15  3 роки тому

      I am glad this video was helpful Khushal :)

  • @PrashantKumar-fg4tg
    @PrashantKumar-fg4tg 3 роки тому +1

    Good explanation,waiting for next video on it.

    • @CodeCat15
      @CodeCat15  3 роки тому

      Thanks Prashant, am glad this was helpful 😊

  • @atmaramsawant6127
    @atmaramsawant6127 3 роки тому +1

    Nice examples Ravi .... enjoying your Shwift tutorials. 😀

    • @CodeCat15
      @CodeCat15  3 роки тому +1

      😊 glad it’s helpful

  • @NamitaMaheshwarinim
    @NamitaMaheshwarinim 3 роки тому +1

    THANKS FOR THIS VIDEO...I REQUESTED A FEW MONTHS AGO FOR THIS...
    THIS IS VERY HELPFUL.
    PLEASE SHARE A TUTORIAL ON DYNAMIC & STATIC DISPATCH

    • @CodeCat15
      @CodeCat15  3 роки тому +2

      I knew i was missing something on threading thanks for reminding me Namita, will work on the video as soon as possible

  • @salmankhan883
    @salmankhan883 2 роки тому +1

    Your explanation is Rock all the time .

    • @CodeCat15
      @CodeCat15  2 роки тому

      Thank you I am glad you found this video helpful, feel free to ask questions and do share the channel with your iOS group.

  • @ranjansahu573
    @ranjansahu573 2 роки тому

    Thanks a lot Sir , its help me lot.

  • @rehanismail7082
    @rehanismail7082 3 роки тому

    Great Tutorial love your tutorial

  • @debikamondal3965
    @debikamondal3965 3 роки тому +1

    Thank you so much for explaining the topic so nicely..

    • @CodeCat15
      @CodeCat15  3 роки тому

      glad it was helpful Debika :)

  • @sharathchandra8298
    @sharathchandra8298 3 роки тому +1

    Very informative . Good Work

  • @diliptilonia
    @diliptilonia 3 роки тому +1

    before this video my ans of difference between GCD vc Operation was GCD is new and operation is older one that's but after this video I got to know the actual difference, thanks Ravi bhai

    • @CodeCat15
      @CodeCat15  3 роки тому

      Hey Dilip hope you are doing well. I am glad this video was helpful to you in knowing the right technical differences between them. Feel free to ask questions and do share the video with your iOS group

    • @nullandvoid5166
      @nullandvoid5166 2 роки тому

      I think Operation queue is older than gcd..it was there before..now It works on top of gcd!!

  • @soumitrabera8130
    @soumitrabera8130 3 роки тому +1

    great videos ..thank you

    • @CodeCat15
      @CodeCat15  3 роки тому

      Am glad these videos are helpful Soumitra

  • @prosenjitkolay2046
    @prosenjitkolay2046 3 роки тому +2

    Thanks, Ravi for these beautifully explained tutorials. I have a question about GCD. What is a queue.cancel() , suspend() and resume()? As you told that we can't pause, resume and cancel (except using dispatchWorkItem) using GCD. Thanks in advance. Hope your viewers and subscriber grow with the growth of these beautiful contents. Wish you good luck.

    • @friendlybittu
      @friendlybittu 2 роки тому

      Hey Hi.. Initially, I had the same question. and then I deep driving on it and find this line of code:
      operationQueue.progress.resume()
      operationQueue.progress.pause()
      operationQueue.progress.cancel()
      Happy Coding... :)

  • @ganeshpadole4601
    @ganeshpadole4601 3 роки тому +1

    clean explanation.

    • @CodeCat15
      @CodeCat15  3 роки тому +1

      Thanks Ganesh do share the video with your iOS group and feel free to ask questions

  • @srinivasgoudjangampet1697
    @srinivasgoudjangampet1697 3 роки тому +1

    Really helpful thank you

  • @fitdevelopertv5148
    @fitdevelopertv5148 3 роки тому +1

    Well explained Ravi

    • @CodeCat15
      @CodeCat15  3 роки тому

      Am glad this was helpful

  • @puneetpal1466
    @puneetpal1466 3 роки тому +1

    Rocks bro :)

    • @CodeCat15
      @CodeCat15  3 роки тому

      Glad this was helpful brother

  • @AmitGupta-ef2nm
    @AmitGupta-ef2nm 3 роки тому +1

    Very good explanation sir

  • @rajdhakate617
    @rajdhakate617 3 роки тому +1

    Good explanation 👍

    • @CodeCat15
      @CodeCat15  3 роки тому

      Thank you Raj, I am glad this was helpful

  • @AboutTheVoice
    @AboutTheVoice 3 роки тому +1

    Thanks you very much sir.

    • @CodeCat15
      @CodeCat15  3 роки тому

      Glad this video was helpful 👍

  • @guidence9151
    @guidence9151 2 роки тому

    Good

  • @connectSanjayMali
    @connectSanjayMali 3 роки тому +4

    Great content Ravi!... have one question since it's on GCD and NSOperation,
    1. How do you fetch millions of record from server. ex 10m users.
    2. And How you gonna store it on to Realm/Core Data.
    3 if user search something from millions of record what could be your approach to display it.

    • @CodeCat15
      @CodeCat15  3 роки тому +8

      Hey Sanjay, good question, I wrote a lengthy reply so do grab popcorn before you read it 😆😆😆. To be honest, such questions are asked more in interviews just to check the analytical skills of a developer, and in my opinion, such large volumes of records should never ever be downloaded on the user's device, to begin with
      It all boils down to your application architecture design, which is what I am going to talk about before I even jump into the code.
      Let's do some math first, if you are calling an API, it won't give you 10 million records directly there's paging like per call you can get a max of 10,000 records, this number depends on your API developers they are free to send even more records not more than that because you don't want to choke the network. So to download 10,000,000 your code should loop around 1000 times to get all that data.
      1000 API calls, per call containing 10,000 records...hmm... what could possibly go wrong.
      Let's go with the assumption that all this data is required for the functioning of your mobile application, then my friend comes the storage issue. You see it's a mobile device, not a SQL or MYSQL database on the cloud which you can scale accordingly so we have a limited storage size to deal with so my question back to you is are you sure that to make your mobile application work you need those 10m records?
      Again if it's yes then how do we plan to address the issue where the user is having a 64GB device and has only 2GB free and it downloads 5 million records from the server and its device storage runs out of space? Do we plan to connect an external hard disk to the iOS device if this happens?
      One of my major concerns here is, if you are downloading huge files/records then in that case not all your users are going to be on wifi, some of them are going to use mobile data, and downloading such humongous records on a mobile data is problematic because then your application is just eating mobile data of the user before even the user starts to use the app.
      Will you use such an app that finishes your data pack before even you use it?
      So what I am trying to say here is there are tons of complications with downloading a large set of data into the user's mobile device, and hence when you design your application you should consider all these complications before writing a single line of code.
      Storing the data in the database is easy, but then how much data you are downloading here raises an eyebrow coz 10million is way too much for a mobile app, but just for the sake of answering this question I will use operation queue for this because it has more features than plain GCD and for downloading such huge volume I could use GCD with super-powers so my answer is operation queue.
      Also searching a huge load of data will take time, even if you want to do a simple search no matter what database you use. If I am using Core Data I make sure to add indexes in the xcdataModel just to give a minor boost to my queries,
      I don't have much exposure on realm to be honest and I have not played with it much to give you an answer based on this complexity but if you really want to download this many records (which I strictly advise against), then you have delta syncs and other complications to deal as explained above so perhaps you may want to look into firebase as an option which handles not all but few complexities for us.
      let me know what you think about it or if you have any other questions I will be happy to answer them.

    • @connectSanjayMali
      @connectSanjayMali 3 роки тому +2

      ​@@CodeCat15 That was amazing explanation bro.
      If the apps having tons of data and still their search functionality works smoothly.

    • @CodeCat15
      @CodeCat15  3 роки тому +1

      @@connectSanjayMali Thanks Sanjay that was a good question, smooth searching totally depends on the volume of data you need to search or filter from, in enterprise applications what should be done is only relevant data should be downloaded as master record rest other should be considered as irrelevant else we have already discussed the issues that can arise in the earlier comments

    • @connectSanjayMali
      @connectSanjayMali 3 роки тому +1

      @@CodeCat15 thank you so much , helping your guidence and content a lot.

    • @PJ-dm5qn
      @PJ-dm5qn 3 роки тому

      @@CodeCat15 this is what I was looking for...
      Thanks a lot for the video and answer. And keep it up.

  • @payalmalekar6529
    @payalmalekar6529 10 місяців тому +1

    Hi Ravi, Thanks for the video, I have one question, what is quality of service, What are the different types of it and when to use each.
    Thank you in adavance.

    • @CodeCat15
      @CodeCat15  9 місяців тому

      Qos is a topic of it's own there are several types that can be used based on what you are doing. Will make a post or video about it. For now here's a developer documentation on the same. Hope that helps
      developer.apple.com/documentation/dispatch/dispatchqos

  • @neelampursnani1637
    @neelampursnani1637 2 роки тому +1

    Thanks Ravi, very nice explanation. I got one question in my mind if Apple handles operations with default property then why max concurrent operation property is given?
    Always it can be handled by default property

    • @CodeCat15
      @CodeCat15  2 роки тому +4

      Let me explain with an example as why priorities are needed
      your senior has given you 3 task, out of those 3 there must be one task which will be high priority
      even if the other two task are not completed it’s fine but this task must be completed today
      So you shift your attention from other two task to this one coz it’s super important or high priority task
      So the other two task has default priority but this one is super high
      All the task can be completed with default priority
      but there can be few task where higher attention is required.
      So with the high priority tag we are instructing the OS that this task which is tagged with high priority is important to us and we need you to complete this first
      Similarly in your module you must think wisely as which task should be tagged with high priority
      Hope that helps, if not then plz feel free to ask more questions I’ll be happy to answer them.

  • @nileshwankhede7420
    @nileshwankhede7420 2 роки тому +1

    Hi Ravi. Thank you for explanation. I have a question about gcd. Can we manage dependency in GCD. If yes then how?

    • @CodeCat15
      @CodeCat15  2 роки тому +1

      For that you may either use the new async await feature or you can use operation queue. It would totally depend on what you want to achieve like if its a nested api call or some calls in parallel or maybe something even more complex which would further need proofing so if you may describe your task or maybe send an email on it with some code that you already did that would put some light on what you want.
      There’s a video on serial api calls if that’s what you are looking for hope it helps
      Link: ua-cam.com/video/II7bJmC64IY/v-deo.html

  • @kalomanik-theghontusingh7791
    @kalomanik-theghontusingh7791 3 роки тому +1

    Can you please post a video on Different type of qualityOfService

    • @CodeCat15
      @CodeCat15  3 роки тому +1

      Yes, I will surely do that thank you for suggesting the video Sumita and welcome to the channel

  • @1ongole1
    @1ongole1 3 роки тому +1

    Very clear explanation that anyone can understand. I have one question... In one of my app I am uploading images to server using the operations and operation queues(creating separate operation for each image to upload and adding it to OperationQueue). And configured maxconcurrentOperations = 5. sometimes what happening is the operation it self is not started executing and it's state never setting to finished(and this operation exists forever in that operation queue), so how to handle this scenarios? Do you have any idea what might be the issue?
    Can you please give some idea why it's not preferrable to set QOS to operation as we are setting it to OperationQueue in this video. what happends if I set QOS to operation instead of Operation Queue. And in which scenarios do I need to set QOS to an operation?
    Also in this video it's good if you explain about QOS, which option to use when...

    • @CodeCat15
      @CodeCat15  3 роки тому +1

      Qos is coming soon as well I didn’t want everything to be explained in one video else its going to be very much overwhelming.
      Apple recommends we should not be setting the max concurrent operation count as its handled by the framework itself as shown in the video but i would have to look at the code as what its doing to comment more on this one.
      I will take a random guess here, operation queue does some calculations within to see how busy the system is so maybe its taking time to figure out how busy the system is and maybe your system was busy and hence it was waiting for the system to be free so that it can launch 5 operations in one go and maybe that’s the reason why apple wants us to keep that value as default coz the operation queue waits for the system to be free to launch the exact number of operations specified in the max concurrent operation property.
      That being said welcome to the channel Monish and thank you for your comment 😊

    • @1ongole1
      @1ongole1 3 роки тому

      @@CodeCat15 Thanks for your quick response. I got what you said and definitely I will revisit my code by setting the maxConcurrentOperations to default. Thanks Ravi.

    • @1ongole1
      @1ongole1 3 роки тому

      @@CodeCat15 one more thing which I felt really good in the video is English subtitles. As few people like me who doesn't know hindi(toda toda aatha hein) they can understand through subtitles.

  • @madhurjain90
    @madhurjain90 3 роки тому +1

    Bro is there code camp or online class you take i would live to join it

    • @CodeCat15
      @CodeCat15  3 роки тому

      Hey Madhur, there’s just UA-cam at the moment. I am not sure if i will be going anywhere apart from UA-cam.

  • @nishadarora1306
    @nishadarora1306 2 роки тому

    I have a question:-

  • @avimitra2406
    @avimitra2406 Рік тому

    Superb 👌

  • @SachinBhardwajhappymoments
    @SachinBhardwajhappymoments 3 роки тому +1

    Explain About Quality of services (QOS)

    • @CodeCat15
      @CodeCat15  3 роки тому

      Hey Sachin after dependencies with API this will be the next video

  • @user-yd9xy3rb4x
    @user-yd9xy3rb4x 2 роки тому +1

    What language was it? I've heard some English words.

    • @CodeCat15
      @CodeCat15  2 роки тому +1

      Welcome to the channel, its in Hindi language which is spoken in India

  • @mazedar_tv
    @mazedar_tv 2 роки тому

    idk I have feeling that in terms of Control. Dispatchgroup is better than OperationQueue. especially if operation is like calling the api

  • @nashtravelandlifestyle
    @nashtravelandlifestyle 11 місяців тому +1

    Starts with English and switches to Hindi, why 😢

    • @CodeCat15
      @CodeCat15  11 місяців тому +1

      Thank you for your feedback. I appreciate your input.
      This channel primarily focuses on Hindi content, and sometimes I mix in English due to my background in Mumbai where this language blend is common.
      I apologize if it has caused any confusion. Feel free to ask questions about the topic, and I'll do my best to provide clarifications.
      Thank you for your understanding!

    • @nashtravelandlifestyle
      @nashtravelandlifestyle 11 місяців тому

      @@CodeCat15 thank you for the reply and sorry for comment if it made feel sad. As this is a big topic I found a playlist with 6 videos which have explaintion in detail.

  • @nishanthnishan1842
    @nishanthnishan1842 2 роки тому

    Please upload videos in English.

    • @CodeCat15
      @CodeCat15  2 роки тому

      Apologies for the inconvenience, but majority of the audience prefer Hindi so I’ll continue in Hindi. You may ask questions if the video was not clear or if you were stuck somewhere I’ll be happy to assist.